Explore BrainMass
Share

Matlab Program to Computer

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

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!

© BrainMass Inc. brainmass.com October 24, 2018, 5:55 pm ad1c9bdddf
https://brainmass.com/engineering/computer-engineering/25170

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 ...

Solution Summary

The solution is given with explanation.

$2.19
See Also This Related BrainMass Solution

Using MATLAB to Generate Random Numbers

This question has 3 parts:

a) Write a computer program using MATLAB to generate random numbers. Use your program to generate, say, 100,000 random numbers. How long did the computer take to generate the random numbers? Roughly how long does it take for the computer to generate a single random number?

b) Using a sample of the random numbers generated in part a, construct a plot of the correlation between successive random numbers (X_i on the x-axis and X_i+1 on the y-axis). Does your random number generator appear to produce random numbers?

c) Compute the mean and standard deviation of the random numbers generated in part a. How do they compare with the mean and standard deviation of a uniformly distributed variable on the range zero to one?

View Full Posting Details