How to find the max value of amplitude in Fast Fourier Transform function?
조회 수: 33 (최근 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에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!