Simulink IFFT complex rounding error?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello Matlab-Community,
when I compute the IFFT in a Simulink Function-Block, the result has a small imaginary part of ~10e-17. When I do the exact same computation in Matlab, I get a real signal. Does anyone know why this happens?
Best regards,
Peter
7 Kommentare
Antworten (1)
Saurav
am 24 Feb. 2024
Hey, Peter,
I understand that when you perform an IFFT computation in Simulink, you obtain a tiny imaginary component in the range of about 10e-17, but when you perform the same computation in MATLAB, you obtain the right results.
It is crucial to note that this is a highly input-specific issue because not all inputs cause it to occur. For example, when attempting to determine the IFFT for the time domain signal, let's say t = [0,1,1,1,1,1,1,1,1,1,0] or [1,0,0,0,0,1], you will observe that the first value at the end of the vector is implicitly repeated while the vector is being processed. Your vector actually looks like this: 0, 1, 1, 1,..., 1, 1, 1, 0, 0, 1, 1, 1,..., 1, 1, 1, 0. The FFT or IFFT in such cases presume that your data is periodic. Observe the consecutive 0’s that appear in between the signal's periods. These types of inputs usually result in round-off errors.
Here is a workaround that you can follow to avoid round-off errors:
- If you know that your input to the IFFT block is conjugate symmetric (which is the case for real-valued time-domain signals), you can enable the “Input is conjugate symmetric” option in IFFT block parameters to expect a conjugate symmetric input. This will ensure that the output is forced to be real.
- Sometimes, switching to a higher precision data type (like double precision) can reduce the effect of numerical errors.
Please refer to the following documentation for an explanation of this epsilon round-off error, which is sometimes inevitable due to finite precision in the computer hardware:
I hope this contributes to your understanding.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!