I am getting incorrect FFT values
Show older comments
Hello,
The values (S) are oscillating around 50 but when i did FFT, I only got at 1.86. I don't know what is wrong with my code. Can someone help me?
%FFT
T=0.01; %cuz the time interval is 0,01. You can see in "t"
Fs=1/T;
t=readtable('t.txt');
S=table2array(readtable('S.txt'));
L=numel(S);
%plot(t,S)
grid on
grid minor
f=Fs*(0:(L/2))/L;
Y=fft(S-mean(S));
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
[pks,locs] = findpeaks(P1, 'MinPeakProminence' ,0.05)
plot(f,P1)
title('Amplitude Spectrums of Aggregat frequency')
xlabel('f (Hz)')
ylabel('Amplitude')
%xlim([0 150])
for k = 1:numel(locs)
xline(f(locs(k)), '-r' , sprintf( 'f = %.2f' ,f(locs(k))))
end
Accepted Answer
More Answers (0)
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
