Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I've started to learn signal fundamentals and I have to do one exercise and I can't understand something.

It is said that $$x[n]=1.5\cos(0.025 \Pi n)(u[n+40]-u[n-40]))$$ and that the signal $u[n-m]$ is a unit step with the value $0$ for $n<m$ and $1$ for $n\geq m$ It is also said that $$y_{1}[n]=0.4*x[n-1] + 0*x[n-2] + 0.3*x[n-3] - 0.4*x[n-4]$$

I have to find the expression and plot the impulse response of the system $y_{1}[n]$

In the example that I have, I have this Matlab code:

n = -40:40;
ind = find(n);
x = zeros(size(n));
x(ind) = 1.5*cos(0.025*pi*n(ind));
h = [0.4 0 0.6 -0.4];
y = conv(x, h);
plot(n, x,'r', n, y(1:end-3),'b');

I understand what goes on from line 1 to 4 but after that I'm lost.

I can see that $h$ is a vector with the multiplying indexes of $x[n]$ on $y_{1}[n]$ but I cant understand what does y = conv(x, h); do. I've came across with the following conv example (MatLab code) but I don't understand how does that values come up.

>> u = [1 2 3 4];
>> v = [10 20 30];
>> conv(u,v)
ans =
10    40   100   160   170   120
>> 

Finally, in the plot, I understand that y(1:end-3) is to make the vectors x and y the same size but why that indexes?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

I'm not sure I can explain it as well as video would, so you should probably checkout youtube.

Basically,

$$\left(\text{conv}(a,b)\right)_n=\sum_{i=-\infty}^{\infty}a_i b_{n-i}$$

So that what happens here is both vectors are padded with zeros on both sides, that is:

u = ... 0, 0, 1, 2, 3, 4, 0, 0 ...

v = ... 0, 0, 10, 20, 30, 0, 0 ...

Then one of them is reversed:

v' = ... 0, 0, 30, 20, 10, 0, 0 ...

Then for every location $n$ you're interested in, you perform a shift left on the second vector by $n$ and perform a dot product.

Eventually you get a vector that's

0

(30,20,10,0,0,0)(0,0,1,2,3,4) = 30*0+20*0+10*1 = 10

(...30,20,10,0,0...)(...0,1,2,3,4...) = 30*0+20*1+10*2 = 40

(...30,20,10,0...)(...1,2,3,4...) = 30*1+20*2+10*3 = 100

(...0,30,20,10...)(...1,2,3,4...) = 30*2+20*3+10*4 = 160

(...0,0,30,20,10...)(...1,2,3,4,0...) = 30*3+20*4+10*0 = 170

(...0,0,0,30,20,10...)(...1,2,3,4,0,0...) = 30*4+20*0+10*0 = 120

0

share|improve this answer
    
Hi.Sorry for the late feedback. Many thanks for your explanation and video –  Favolas Mar 3 '13 at 22:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.