Multiple convolutions in Matlab

 ̄綄美尐妖づ 提交于 2019-12-08 00:44:45

问题


I want to numerically calculate several convolutions like

where the x, y, z, w functions are given in the below code:

t = linspace(-100,100,10000);

x = t.*exp(-t.^2);
y = exp(-4*t.^2).*cos(t);
z = (t-2)/((t-2).^2+3^2);
w = exp(-3*t.^2).*exp(2i*t);

u = conv(conv(conv(x,y),z),w);

plot(t,u) % ??? - if we want to convolute N functions, what range should t span?

Is this the most efficient way to calculate and plot multiple convolutions? Is it generally better to numerically integrate the functions for each convolution?

Edit:

This is the plot of the real part of my convolution, u vs t:

whereas the method (using FFTs) suggested by a poster below gives me:

What causes this discrepancy?


回答1:


If the signal length is long, fft method would be better.

Below is an example.

t = linspace(-100,100,10000);

x = t.*exp(-t.^2);
y = exp(-4*t.^2).*cos(t);
z = (t-2)/((t-2).^2+3^2);
w = exp(-3*t.^2).*exp(2i*t);

L_x=fft(x);
L_y=fft(y);
L_z=fft(z);
L_w=fft(w);

L_u=L_x.*L_y.*L_z.*L_w; %convolution on frequency domain

u=ifft(L_u); 

figure(1)
plot(t,abs(u))
figure(2)
plot(t,real(u))
figure(3)
plot(t,imag(u))


来源:https://stackoverflow.com/questions/37958662/multiple-convolutions-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!