MATLAB program to find convolution of two signals

This is a MATLAB program to find convolution of two signal.TO do this just follow simple step given below.
[1] Open MATLAB and click on File -> New ->

[2] Write a code in that m-file which is given below.

t=0:0.1:100;
x=sin(t);
h=cos(t);
subplot(2,2,1)      
plot(x)
subplot(2,2,2)
plot(h)
n1=length(x);
n2=length(h);
X=[x,zeros(x, n2)];
H=[h,zeros(h,n1)];
for i=1: n1+n2-1
y(i)=0;
for j=1:n1
if(i-j+1>0)
y(i)= y(i)+X(j)*H(i);
end

end
end
subplot(2,2,3)
plot(y)

[3] After writing this code save it and run it you will get output as shown below.


Comments

Popular posts from this blog

MATLAB program to find Frequency Modulation