Problem with FFT amplitude plot
2 ビュー (過去 30 日間)
古いコメントを表示
I have a dataset of nearly 3 hour duration. There are 30 sec interval of data points. I want to find the amplitude spectrum of data after performing FFT. And x axis will be periods in minute. But after applying fft I am not getting desired results.
If you can help me in this regard I will be grateful...and also Thanks in advance
2 件のコメント
dpb
2020 年 8 月 8 日
See the example PSD calculation via FFT in the documenation for FFT
doc fft
There's nothing anybody can tell you about any specific problem you're having from the above general description -- no data, no code, no nothing...
回答 (3 件)
Star Strider
2020 年 8 月 14 日
To see the frequency peaks, it is necessary first to remove the D-C offset by subtyracting the mean of the signal:
D1 = readmatrix('data.xlsx');
t = D1(:,1);
data = D1(:,2);
figure
plot(t, data)
grid
L = numel(t);
Ts = mean(diff(t));
Fs = 1/Ts;
Fn = Fs/2;
datam = data - mean(data);
FTdata = fft(datam)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
[pk,ix] = max(abs(FTdata(Iv)));
figure
plot(Fv, abs(FTdata(Iv)))
hold on
plot(Fv(ix), pk, '^r')
hold off
grid
text(Fv(ix), pk, sprintf('\\leftarrow Frequency = %7.3f\n Amplitude = %7.3f', Fv(ix), pk), 'HorizontalAlignment','left')
producing:
Now, the main peak is clearly visible. (Note that there is some variation in the sampling times, so it would be best to use the resample function to make them all equal and therefore impprove the precision of the result.)
.
0 件のコメント
Antonio Ciociola
2020 年 8 月 8 日
It's hard to understand the problem without data and code.
The error that you get seems related to the amplitude of the spectrum so it's possible that you have forgotten to normalize the spectrum dividing by the number of samples.
Xs = (1/length(x))*fft(x);
0 件のコメント
Moon Datta
2020 年 8 月 9 日
5 件のコメント
Antonio Ciociola
2020 年 8 月 14 日
Look at the answer that Star Strider. He suggests to remove the DC offset to see the frequency peaks but it seems that you have another problem.
The image that you've showed seems to suggest that you have a signal without DC component and with some higher frequency components.
Looking at the photo that Star Strider posted you could get the same consideration made before:
"Look at the result that I get. Is it useful? In my opinion this plot it's "telling" that the signal has a quasi zero frequency...and it seems quite correct because looking at the signal it has very slow variation and poor periodicity."
And it's different from the result showed in the photo that you posted above.
So the question is...are you sure that the result in the photo it's obtained with the same data? Maybe you need to observe the signal for a long time to appreciate it's periodicity.
参考
カテゴリ
Help Center および File Exchange で Fourier Analysis and Filtering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!