u/FloridaMan_2023

▲ 4 r/matlab

Help! Question About Convolution Integral Implementation in Simulation

Hello all! Hoping someone can help me out with this. I am working on a physics simulation of a rigid body.

I have two functions, f and g that need to be convolved over time. Here is the difficulty, both functions are unpredictable and therefore I do not know these equations up front and will only know the latest value of each of those functions at each time step in the simulation as it runs. I solved this convolution integral in the time domain as a baseline and compared it to a textbook solution. Obviously, the longer the simulations the more data points the equation has to convolve over. I tried solving it in the frequency domain thinking it would save time by: *ifft(fft(F)fft(G))\*timestep*
When I run a code profiler (doing this in MATLAB), it actually appears that it is taking longer computationally to solve this in the frequency domain versus the time domain if this operation is done at every time step… what am I missing here (yes I even varied the simulation time length to account for different array sizes)? The other thought I had was to figure out how to implement a sliding window so that really old data is excluded…

Any examples I can find online all assume the equations for the two signals to convolve are known up front. What approach did you use? Any help would greatly be appreciated.

reddit.com
u/FloridaMan_2023 — 1 day ago