clear all x=input('Enter x(ie:[2 3 1]): ') h=input('Enter h(ie:[1 1 1]: ') fprintf('This demonstrates conv function:'); con=conv(x,h) length_x=length(x); %these are the lengths length_h=length(h); length_s=length_h+length_x-1; X=[x,zeros(1,length_h)]; H=[h,zeros(1,length_x)];
for i=1:length_s
Y(i)=0; %setting y value for j=1:length_x if(i-j+1>0) Y(i)=Y(i)+X(j)*H(i-j+1); end end
end stem(Y) fprintf('Results of the output matches above:'); Y