0% found this document useful (0 votes)
27 views

Successful Programs

This document describes linear convolution using MATLAB. It defines an input vector x and impulse response vector h. It then performs convolution on x and h using the in-built conv function and by manually calculating the sum, and plots the results to compare the two methods.

Uploaded by

tkpradhan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Successful Programs

This document describes linear convolution using MATLAB. It defines an input vector x and impulse response vector h. It then performs convolution on x and h using the in-built conv function and by manually calculating the sum, and plots the results to compare the two methods.

Uploaded by

tkpradhan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Linear Convolution:

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)');

You might also like