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

27 vues (au cours des 30 derniers jours)
Michael Wang
Michael Wang le 9 Mai 2020
Commenté : Peng Li le 11 Mai 2020
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);

Réponses (1)

Peng Li
Peng Li le 9 Mai 2020
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 commentaires
Peng Li
Peng Li le 11 Mai 2020
what do you mean by solution?
Peng Li
Peng Li le 11 Mai 2020
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by