Discrete convolution in time/Laplace domain

12 visualizaciones (últimos 30 días)
Peter Uwsen
Peter Uwsen el 17 de Jun. de 2024
Comentada: Peter Uwsen el 21 de Jun. de 2024
Hello,
I'm dealing with a problem where I need to calculate a convolution in the time domain again and again, so efficiency is a big issue.
I need to evaluate the following formula
numerically. I know as a analytical function (which btw can also be transformed analytically in the time domain); but I have only as discrete values . That means I need to evaluate in discrete form to obtain .
I have used FFT to solve some convolution in the Fourier space, but this Laplace transforms seem to be much more challenging numerically. Is maybe z-transforms the way to go? I would be very thankfull for any guidance on the topic.
Thank you.
  2 comentarios
Paul
Paul el 17 de Jun. de 2024
Hi Peter
Are the q_i that you have uniformly sampled in time? Do you have their associated time tags? Do you have any information or assumptions about q(t) for t less than the time tag associated with q_1 or t greater than the time tag associated with q_n? Any assumptions on the form of q(t) between the samples of q_i?
Peter Uwsen
Peter Uwsen el 17 de Jun. de 2024
Hi Paul,
Thanks for your answer!
Yes, I have q_i uniformly sampled in time, and I have the assiociated time tags. for t < 0, so before q_1, q is zero. For the time after q_n, I dont have any information. I think between the q_i q(t) can simply be linear.

Iniciar sesión para comentar.

Respuesta aceptada

Paul
Paul el 17 de Jun. de 2024
Simplest and most efficient approach would be to compute samples r_i = r(i*T) where T is the sampling period and then use conv to approximate the convolution integral, i.e.,
u = T*conv(q,r);
Make sure to take enough samples r_i such that r(t) is equal to, or well appoximated by, zero outside the interval covered by the samples. This approach is simpler if r(t) = 0 for t < 0, but can still be implemented even if r(t) ~=0 for t < 0.
If q and/or r have lots of samples, the consider using cconv, which uses and FFT based approach that might be faster.
If you're willing to assume that q(t) is linear between its samples, then you can use interp1 to interpolate to an effectively higher sampling period before sampling r(t) and doing the convolution.
If you'd like, feel free to post an example and your code. The data in q can be saved in .mat file and uploaded using the Paperclip icon on the Insert menu, unless you can define q by an equation as an example. If you have R(s) as a sym, then you can include that in the .mat file as well. Otherwise, a picture (use the Image icon on the Insert menu) should be fine if R(s) isn't too complicated.
  7 comentarios
Paul
Paul el 20 de Jun. de 2024
I've suggested above to investigate cconv, which uses the fft/ifft approach and may be a lot faster for large data sets. cconv does come with some small overhead. Interestingly, it does not pad to nextpow2 in an attempt to gain some efficiency. Search the doc for "Linear and Circular Convolution" to see how to correctly use fft/ifft to perform linear convolution if you want to roll your own.
rng(100);
N = [1e3 1e6];
for n = N
q = rand(1,n);
r = rand(1,n);
tic,c1 = conv(q,r);toc
tic,c2 = cconv(q,r);toc
norm(c1-c2,'inf')
end
Elapsed time is 0.039565 seconds.
Elapsed time is 0.029024 seconds.
ans = 5.6843e-13
Elapsed time is 8.851229 seconds.
Elapsed time is 0.181574 seconds.
ans = 2.6368e-08
Peter Uwsen
Peter Uwsen el 21 de Jun. de 2024
Ok great, thank you! I will check the doc.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surrogate Optimization en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by