How to find the max value of amplitude in Fast Fourier Transform function?

38 ビュー (過去 30 日間)
Michael Wang
Michael Wang 2020 年 5 月 9 日
コメント済み: Peng Li 2020 年 5 月 11 日
The question is aksing to find the max value of amplitude in Fast Fourier Transform function and display the related requency value named as freq_max
Here is the sample codes I have done below.
The last two raws of the codes I have done is based on this webpage Q&A
I am not really sure if this method is correct for me to solve in Fast Fourier Transform function issue?
% the head of coding is to read any data as xxx.csv
% because it is not the main issue of the problem, so I ignore those coding to make the rest of the coding clearly.
Fs = 360.;
T = 1./Fs;
L = length(ecgData);
t = (0:L-1)*T;
% Set up for FFT
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
%Calculate the FFT of the ecg data
Y = fft(ecgData,NFFT);
%Construct the points along the frequency axis
freq = Fs/2*linspace(0,1,NFFT/2+1);
SSAS = 2*abs(Y(1:NFFT/2+1));
%[SSAS_max, index] = max(SSAS);
%freq_max = freq(index);

回答 (1 件)

Peng Li
Peng Li 2020 年 5 月 9 日
I believe it is correct. you can always test it by plotting them.
plot(freq, SSAS); hold on; plot(freq_max, SSAS_max, 'ro');
and see if they match.
  3 件のコメント
Peng Li
Peng Li 2020 年 5 月 11 日
what do you mean by solution?
Peng Li
Peng Li 2020 年 5 月 11 日
A possible issue is that the DC is dominating the spectrum. try to remove the DC by ecgData - mean(ecgData) before fft
Y = fft(ecgData - mean(ecgData), NFFT);
, or using detrend function.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by