How to use Convolution in Simulink?
3 ビュー (過去 30 日間)
表示 古いコメント
Hi, I make the block using Convolution funtion, but the results was not I wanted.
The program is below.
function y = fcn(u1, u2)
y=conv(u1,u2);
The u1 and u2 both are input which has [1001×1] matrix in total 10s simulatin time.
I want to solve it as below.

which n=1001.
However, in Simulink, Only product calculation for each sample time is executed.
Just like

So the results is same as just use produc function.
How to make the program with the first formula in Simulink?

回答 (2 件)
Andy Bartlett
2022 年 7 月 1 日
You can quickly model this BEHAVIOR using the
two Tapped Delay blocks
one Dot Product block
I emphasized BEHAVIOR because you will be doing 1001 multiplies at every time step and 1000 additions at every time step.
But at the first time step, 1000 of the multiplications will involve multiplication by zero, so output at the first time step will behave like the
w(1) = u(1) * v(1)
you are seeking, but it will be implemented as
w(1) = u(1) * v(1) + 0 * 0 + 0 * 0 + ... + 0 * 0
the zeros come initial conditions of the tapped delay blocks.
At the second time step, 999 multiplications will be zeros, and so on.
Note with the Tapped Delay, you'll want one configured as Oldest first and the other as Newest first.
I think you'll also want to check "Include current input in output vector"
Paul
2022 年 7 月 2 日
I think this model does what you're looking for.
Here is the model that uses the convolution sum to approximate the convolution integral of u1(t) = 1 and u2(t) = exp(-t). I used those u1(t) and u2(t) because I know what the answer should be and so could check it.

The sampe Time is Ts = 0.01.
The fcn code is:
function y = fcn(u1,u2)
persistent n
if isempty(n)
n = -1;
end
n = n + 1;
y = sum(u1(end-n:end).*fliplr(u2(end-n:end)));
end
And the output is:

which is y(t) = 1 - exp(-t).
There may be simpler and/or better ways to do this.
Also, the model will have problems if the number of delays in the Tapped Delay is too small relative to Tfinal/Ts.
If I may ask, what is the application that needs to compute the convolution integral in simulation?
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!