ecg signal frquency contents
10 views (last 30 days)
Show older comments
I need to determine frequncy contents of an ecg signal which i have loaded from a file , but the sampling frequency is Fs=1.0e+04 * 1.7869 I used fft , but when i plot i get frequencies close to zero .
X1=load( ) sig = load(fn) ; sig=x1(:,2); t=x1(:,1); Ls=length(sig); Fs=Ls/t(end)-t(1); I get : Fs=1.0e+04 * 1.7869 Nfft=2^nextpow2(Ls) Y = fft(sig,Nfft)/Ls; f=Fs/2*linspace(0,1,Nfft/2+1); subplot(2,1,2) plot(f,abs(fftshift(Y(1:Nfft/2+1))))
0 Comments
Accepted Answer
Mohamad
on 7 Jun 2018
2 Comments
Sandro Lecci
on 7 Jun 2018
Dear Moh,
If I run your code on your data, this is what I get after I zoom in the low frequencies.
As you see, most of the "activity" can be seen <10 Hz. Would you like to extract the sympathetic/parasympathetic activity from it? Then you should first extract the heart rate variability value (calculate the interval between consecutive R-waves) and perform the same analysis (frequency extraction).
Best, Sandro
More Answers (1)
Sandro Lecci
on 6 Jun 2018
Dear Moh,
I recommend you substract the signal average to get rid of the very low frequencies.
Just write this:
Y = fft(sig-mean(sig), Nfft)/Ls;
Best, Sandro
1 Comment
Sandro Lecci
on 7 Jun 2018
Could you please do the following on your last comment:
-highlight the portion of code -hit the "code button" to display it in a more readable way
I personally do the fft calculation slightly different (I don't use fftshift) but I assume the theory behind is correct. What is strange is the X-axis, it should be centered to zero, which makes your whole spectrum range from 0 to ~500 and considering the properties of an ECG signal you should focus on the low frequencies (LF and VLF) that range < 1Hz.
to calculate the power I do the following:
Fs = 1000; %Hz
xfreq = linspace(0,1, length(signal)/2+1)*(Fs/2); %calculate x frequency vector
tempfft = abs(fft(signal- mean(signal))); %perform fft and extract the real part of it
tempfft = tempfft./length(signal); % divide by the number of samples
tempfft = tempfft.^2; %square it
tempfft = tempfft./xfreq(2); % calculate PSD by dividing by the frequency resolution (second point in the xfreq vector)
myFFT= tempfft(1:end/2+1); % take the first half of it
plot(xfreq,myFFT); xlabel('Frequency'); ylabel('PSD')
Best,
See Also
Categories
Find more on ECG / EKG in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!