Problem with FFT amplitude plot
3 次查看(过去 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!