You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
For several different reasons it could occur that we need to produce a signal from the sum of several harmonic components. In the usual case of Fourier analysis, FFT and IFFT are likely the best choice. However it could happen that:
- The frequencies of the harmonic components are unevenly spaced
- The time vector is unevenly spaced
In such cases we could be in the need of coding the summation directly in Matlab, that is quite slow in performing this tasks.
The provided function is simply a MEX file that performs the signal generation through a compiled FORTRAN code.
Nothing special, but at least I run the generation almost three times faster than in Matlab. Not as good as in the cases where you can use IFFT directly in Matlab, but at least a little bit better than using a "for" loop directly in Matlab.
Cite As
Gabriele (2026). Sum of harmonics (https://au.mathworks.com/matlabcentral/fileexchange/12508-sum-of-harmonics), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.0.0 (6.71 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0.0 | Better explanation of the fact that the speed is increased with respect to the standard for loop in matlab |
