Can some one please tell me how to find the maximum amplitude frequency of the ecg signal? I have attached below my code. I keep getting maximum frequency at 0 Hz.

조회 수: 14 (최근 30일)
function [freq,SSAS,freq_max] = tutorial10
% Read in the data file
filename = 'data.csv'; % Filename
delimiterIn = ','; % Entries are comma delimited
headerlinesIn = 0; % No header
ecgData = importdata(filename,delimiterIn,headerlinesIn); % Read the file into an array called ecgData
% Calculate (but don't plot) single-sided amplitude spectrum (this includes points along frequency axis, and amplitude axis)
% Determine frequency which exhibits maximum amplitude
% Set up for FFT
T = 1./360; % Sample time
Fs = 1/T; % Sampling frequency
L = length(ecgData); % Length of signal (total samples)
t = (0:L-1)*T; % Time vector
%Calculate the FFT of the ecg data
NFFT = 2^nextpow2(L); % Next power of 2 from length of signal
Y = fft(ecgData,NFFT);
ecgData =ecgData -mean(ecgData);
SSAS =2*abs(Y(1:NFFT/2+1));
%Construct the points along the frequency axis
freq = Fs*linspace(0,1,NFFT/2+1);
max_a= max(Y);
idx = find(Y == max_a);
freq_max = freq(idx)
% Create filter
Fcutoff=30;
order=2;
cutoff=2*Fcutoff/Fs;
end

채택된 답변

Peng Li
Peng Li 2020년 5월 11일
try
Y = fft(ecgData - mean(ecgData), NFFT);
It is expected that the DC contains most of the energy of the signal. You could explictly remove this DC component, or you can try something like detrend to remove the nonstationary trend which is usually quite common in physiological data.
  댓글 수: 4
Peng Li
Peng Li 2020년 5월 11일
I guess you should use max(SSAS) instead of max(Y). Y is complex. SSAS based on your codes is amplitude spectrum.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by