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.

9 次查看(过去 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 个评论

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by