Write MATLAB functions for the following a Wrtie a convoluti

Write MATLAB functions for the following:

a) Wrtie a convolution function x*h(x-signal,h-impulse response) where size of a vector x is 1XM and size of vector h is 1xN. The output should be of length 1x(M+N-1):

function out = Convolution(x,h).....

b) vector u=[1 1 1] and vectov v=[ 1 1 0 0 0 1 1] and covolute them using conv() with different shape arguments. Plot them and explain how theyre different.

Solution

(a)

function [x]=convolution(a,b)

l1=length(a);

l2=length(a);

x=zeros(1,l1+l2);

for i=1:1:l1

for j=1:1:l2

x(1,i+j)=x(1,i+j)+a(i)*b(j);

end

end

x=x(2:l1+l2);

end

(b)

u=[1 1 1];

v=[1 1 0 0 0 1 1];

convolution(u,v);

OUTPUT:

ans =
1 2 2 1 0
>>

Write MATLAB functions for the following: a) Wrtie a convolution function x*h(x-signal,h-impulse response) where size of a vector x is 1XM and size of vector h

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site