Successful Programs
Successful Programs
x=[1 2 2 1]; h=[2 3 1 4]; xl=length(x); hl=length(h); len=xl+hl-1; tl=1:xl; subplot(2,2,1),stem(tl,x); title('The Input function'); xlabel('x(n)'); tl=1:hl; subplot(2,2,2),stem(tl,h); title('The Impulse function'); xlabel('h(n)'); x=[x zeros(1,hl)]; h=[h zeros(1,xl)]; %Convolution using in-built convolution function y=[zeros(1,len)]; rsl=1:len; y=conv(x,h); subplot(2,2,3),stem(rsl,y); title('Result using conv function'); xlabel('y(n)'); %Convolution without using in-built convolution function Y=[zeros(1,len)]; for n=1:len s=0; for k=1:n s=s+(x(k)*h(n-k+1)); end Y(n)=s; end subplot(2,2,4),stem(rsl,Y); title('Result without using conv function'); xlabel('y(n)');