How to find the max value of amplitude in Fast Fourier Transform function?
9 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
回答(1 个)
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
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 Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!