Adding Harmonics of a sine wave together
3 ビュー (過去 30 日間)
古いコメントを表示
I have extracted harmonics of a sine wave through 'fft' in matlab. I considered the phase to define the signs of each harmonics - a two sided psd is shown in fig below. However when I add the first 8 harmonics, I do not get the exact sine wave as shown in fig below. Can some one help?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/454478/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/442408/image.jpeg)
2 件のコメント
Bjorn Gustavsson
2020 年 12 月 8 日
To get help from others you cannot remove the plot with the original function and your sum-of-sines approximations.
回答 (1 件)
Bjorn Gustavsson
2020 年 12 月 3 日
You have to take into account that the fft returns complex Fourier-coefficient - that is both real and imaginary components. So you have to use both sin and cos - terms in your sum, also the average of the signal is not zero so you should have a negative (?) DC-component giving you a constant off-set, that is absent from your plot.
HTH
2 件のコメント
Bjorn Gustavsson
2020 年 12 月 4 日
No.
The Fourier-series approximation of your periodic signal is:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/444893/image.png)
For your second "original curve" (orange with '.-') it is not the case that the average (DC-component) is zero, therefore a_0 is smaller than zero, and cos(0) is equal to 1. Since it is non-zero you have to use that term in your sum-of-Fourier-terms. It seems rather plausible that some of the other cosine-coefficients also are non-zero and they also have to be included.
参考
カテゴリ
Help Center および File Exchange で Spectral Measurements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!