In: Electrical Engineering
MATLAB’s conv() function produces an output that is longer than both the original impulse response and input signals. We will look more at this in the discrete-time signals and systems unit, but think about why this might be happening and how to deal with this when plotting your resultant output.
% MATLAB code for verification
clc
clear all
close all
n= -25:25
x= cos(2*pi*n/.3).*(n>=0)
h= (sin(pi*n/3)/sqrt(3)).*(n>=0)
y= conv(h,x)
n1 = -25:length(y)-1-25 %length is change to n1 (remove this n1 and
plot you will see error
plot(n,x)
hold on
plot(n,h)
hold on
plot(n1,y)
title ('Plot of input X[n], impulse response h[n] and the
convolution of the two Y[n]')
xlabel ('Variable n')
ylabel ('amplitude')
hold on