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.
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Siratul Srotoshwini
il 11 Mag 2020
Commentato: Peng Li
il 11 Mag 2020
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
0 Commenti
Risposta accettata
Peng Li
il 11 Mag 2020
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 Commenti
Peng Li
il 11 Mag 2020
I guess you should use max(SSAS) instead of max(Y). Y is complex. SSAS based on your codes is amplitude spectrum.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!