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?