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

26 visualizaciones (últimos 30 días)
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);

Respuestas (1)

Peng Li
Peng Li el 9 de Mayo de 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 comentarios
Peng Li
Peng Li el 11 de Mayo de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by