Purchase Solution

Matlab Program to Computer

Not what you're looking for?

Ask Custom Question

Hi. Please help me with this Matlab.

x(n)=(1,2,3,4,5,6,7,8,9,10)
h(n)=(1,1,-1,3,2)
Write a matlab program to computer y(n)=h(n)*h(n) (convolution) without using the matlab convolution function 'conv'. That is, write matlab code to computer the convolution sum (... using nested loops?). Then use conv(h,x) to check the work.

Plot h, x, and y using the plot function.

--

This is what I have:
x=[0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,0,0,0,0,0,0,0,0,0,0,0,0];
h=[0,0,0,0,0,0,0,0,0,0,1,1,-1,3,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
y=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];

for n=-5:15,
for k=-100:100,
y(n+10)=y(n+10)+x(k+10)*h((n+10-(k+10)));
end;
end;

for z=-5:15,
disp (y(z+10));
end;

---

The problem is that negative indices cannot be used - so I was trying to zero pad both sets. This seems to be okay, but for k being -infinity to +infinity and all, I'm stuck. I tried moving it to -100 to +100 but I get confused. I even tried drawing cells on a paper to visually see how to convolution is to be one, but I got even more confused.

Please correct the program so that it works. Thank you!

Purchase this Solution

Solution Summary

The solution is given with explanation.

Solution Preview

Convolution is the same operation as multiplying the polynomials whose coefficients are the elements of u and v. DefinitionLet m = length(u) and n = length(v). Then w is the vector of length m+n-1 ...

Purchase this Solution


Free BrainMass Quizzes
Architectural History

This quiz is intended to test the basics of History of Architecture- foundation for all architectural courses.