What is my Y axis and what does it depend on

4 visualizaciones (últimos 30 días)
Bruce Pollom
Bruce Pollom el 3 de En. de 2018
Respondida: Benjamin Kraus el 3 de En. de 2018
Fs = 1000;
Ts = 1/Fs;
t=-1:Ts:1;
%u(t-0.5)
step = zeros(size(t));
step(t>=0.5) = -1;
figure
grid
plot(t,step)
%u(t+0.5)
step2 = zeros(size(t));
step2(t>=-0.5)= 1;
figure
grid
plot(t,step2)
xt=step2+step;
figure
plot(t,xt)
y = conv(xt,xt);
t3 = -2 :Ts:2;
figure
plot(t3,y)
z = conv (y,xt );
t4= -3:Ts:3;
figure
plot(t4,z)
q = conv(z,xt)
t5 = -4:Ts:4
figure
plot(t5,q)
Hello, so I have this code which is supposed to convolute a signal with himself 3 times. In the first convolution the y goes up to 1000 and at the 2nd one even higher. I'm assuming its the amplitude but how do I control it ? Theoretically, for the first convolution ( the triangle ), the amplitude should still be 1 ?

Respuestas (1)

Benjamin Kraus
Benjamin Kraus el 3 de En. de 2018
Let's start with something simple:
x = [0 2 1 0];
y = [0 1 3 0];
z = conv(x,y);
plot(z);
A convolution shifts one matrix next to the other, then multiplies the values that line up, and sums the result. The output z above is: [0 0 2 7 3 0 0]. Let's look at each element of that output matrix:
z(1) = 0 = x(1)*y(1) + x(2)*0 + x(3)*0 + x(4)*0;
z(2) = 0 = x(1)*y(2) + x(2)*y(1) + x(3)*0 + x(4)*0;
z(3) = 2 = x(1)*y(3) + x(2)*y(2) + x(3)*y(1) + x(4)*0;
z(4) = 7 = x(1)*y(4) + x(2)*y(3) + x(3)*y(2) + x(4)*y(1);
z(5) = 3 = x(1)*0 + x(2)*y(4) + x(3)*y(3) + x(4)*y(2);
z(6) = 0 = x(1)*0 + x(2)*0 + x(3)*y(4) + x(4)*y(3);
Notice how on each of the lines (except #4) there are some terms that are 0 because the two vectors are not completely overlapped. The peak value comes from the point of maximal alignment between the two vectors, but the actual value depends on which elements of x align with other elements of y.
Applying the same method to two simple step functions:
x = [0 1 1 0];
y = [0 1 1 1 0];
z = conv(x,y);
The output is z = [0 0 1 2 2 1 0 0].
Those middle 2 values are basically the maximum possible overlap between x and y, because x has only two consecutive 1 elements which can align with the 1 elements in y.
Your input vector is a step function with 1000 consecutive 1 values. The point of maximal alignment will be when the two vectors are right next to one another (no shift relative to one another), so effectively you have 1000 occurrences of 1*1 which produces 1000. That is why the peak value in your first convolution is 1000.
If you shift the two vectors by just one element, then one less element aligns, resulting in a value of 999. One more shift leaves a value of 998 and so on until you hit 0. This produces the triangle that you see in your first convolution.
The second time around, when you do conv(y,xt) you have the first vector xt which still has a segment of 1000 values equal to 1. The other vector now has a segment that is 1999 elements long that increases from 1 to 1000 then back down to 1. The point of maximum alignment will be when the two vectors are centered with one another. The peak value will then be effectively:
max = 500*1 + 501*1 + ... 998*1 + 999*1 + 1000*1 + 999*1 + ... 502*1 + 501*1;
In other words:
sum([500:1000 999:-1:501]) = 750000
The same pattern as before produces the gradual decline in the value as the two vectors come out of alignment with one another, which when repeated produces the bell-curve shape.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by