MATLAB: HOW TO FİND PEAKS OF FFT

i need to find the peaks of this fft and i tried something and those are above but i could not find coorect solution. can someone help me?

F=GA2L5E1(:,4); % Data Channel
Ts = 5E-5; % Sampling Interval (s)
Fs = 1/Ts; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency
F(isnan(F))=[]; % Eliminate ‘NaN’ Values First
LF = size(F,1); % Length of Data Vector
T = linspace(0,1,LF)*Ts; % Create Time Vector
figure(1) % Plot Data
plot(T, F)
grid
FF = fft(F)/LF; % Fourier Series of Data, Freq Vector
Fv = linspace(0,1,fix(LF/2)+1)*Fn;
Iv = 1:length(Fv); % Index Vector
figure(2) % Plot FFT
plot(Fv, abs(FF(Iv)))
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
axis([0 1500 ylim])
x = abs(FF);
figure()
[pks, locs]=findpeaks(x);
plot(locs, pks, 'or')
hold on;
plot(x)
[pks, locs]=findpeaks(x, 'MinPeakDistance',50, 'minpeakheight',0.002);

Best Answer

I recognise my code!
The second plot call is almost correct.
Try this:
[pks, locs]=findpeaks(x(Iv));
plot(Fv(locs), pks, 'or')
It is necessary to restrict the findpeaks argument to ‘x(Iv)’ because otherwise the vector lengths will not match and so will not plot correctly.
I am not certain what you are doing with the second findpeaks call, hgowever a plot using those values would be essentially the same.