reading frequency from fft

조회 수: 7 (최근 30일)
uzmeed
uzmeed 2018년 1월 27일
편집: Youssef Khmou 2018년 1월 30일
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