reading frequency from fft

3 次查看(过去 30 天)
uzmeed
uzmeed 2018-1-27
I want to read the frequencies of all peaks of fft the following program is not reading it correctly instead of giving 100 and so its giving output as 360 400 or so please help how can I get value of the freq
Fs = 65536; % Sampling Frequency (Hz) Ts = 1/Fs; % Sampling Interval (sec) Fn = Fs/2; % Nyquist Frequency (Hz) L = 16384; % Signal Length (samples) t = [0:(L-1)]*Ts; % Time Vector (sec) s = cos(2*pi*100*t);% Signal (100 Hz) figure(1) plot(s) FTs = fft(s,Fs)/L; % Experiment #1 Fv = linspace(0, 1, fix(Fs/2)+1)*Fn; Iv = 1:length(Fv); [PeakFTs,Idx] = max(abs(FTs(Iv))*2); % Find MAximum and Index figure(2)
plot(Fv, abs(FTs(Iv))*2) axis([0 500 ylim]) grid
f = Fs/2*linspace(0,1,L/2+1); [B,IX] = sort(2*abs(FTs(1:L/2+1))); %order the amplitudes A1=B(end); %amplitude of the first peak A2=B(end-1); %amplitude of second peak f1=f(IX(end)); %frequency of first peak f2=f(IX(end-1)); %frequency of second peak BFloor=0.1; %BFloor is the minimum amplitude value (ignore small values) Amplitudes=B(B>=BFloor) %find all amplitudes above the BFloor Frequencies=f(IX(1+end-numel(Amplitudes):end)) %frequency of the peaks
regards uzmeed

回答(2 个)

Youssef  Khmou
Youssef Khmou 2018-1-27
The first part of the program is correct, the result is 100 Hz:
Fs = 65536; % Sampling Frequency (Hz)
Ts = 1/Fs; % Sampling Interval (sec)
Fn = Fs/2; % Nyquist Frequency (Hz)
L = 16384; % Signal Length (samples)
t = [0:(L-1)]*Ts; % Time Vector (sec)
s = cos(2*pi*100*t);% Signal (100 Hz)
figure(1),plot(s),
FTs = fft(s,Fs)/L; % Experiment #1
Fv = linspace(0, 1, fix(Fs/2)+1)*Fn;
Iv = 1:length(Fv);
[PeakFTs,Idx] = max(abs(FTs(Iv))*2); % Find MAximum and Index
figure(2)
plot(Fv, abs(FTs(Iv))*2),
axis([0 500 ylim]),grid on;
The frequency value is
>>Fv(Idx)

uzmeed
uzmeed 2018-1-27
Than you Youssef It helped me Please guide that if the input is a frequency modulated signal with multiple valid peaks in fft then how can all peak be listed correctly .
I have attached a jpg for reference butt input is ant LFMOP signal
best regards Uzmeed
  1 个评论
Youssef  Khmou
Youssef Khmou 2018-1-30
编辑:Youssef Khmou 2018-1-30
for the case of mutiple peaks, you can use a peak detection procedure, and if the waveform is given by frequency that varies with continous rate then you can per example compute the with of the spectrum at half maximum to estimate the bandwidth.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Measurements and Feature Extraction 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by