Has
Has

Reputation: 885

FFT of ECG signal in MATLAB

This is the input signal : original

    plot(abs(fft(ecg)))

fft

I have also tried

    fvtool(x_vals)

which gave me :

another

However I want the x axis in Hz. So essentially I want to see the frequency spectrum of this signal in Hz.

Thanks!

Upvotes: 2

Views: 11066

Answers (1)

s-m-e
s-m-e

Reputation: 3729

function [f amp] = getspectrum( Mdata, Mf )

%  Mdata    data 
%  Mf       sampling rate / frequency (Hz)

NFFT = 2 ^ nextpow2(length(Mdata)); 
Y = fft(double(Mdata), NFFT) / length(Mdata);
f = (double(Mf) / 2 * linspace(0, 1, NFFT / 2))'; % Vector containing frequencies in Hz
amp = 2 * abs(Y(1:(NFFT / 2))); % Vector containing corresponding amplitudes

I hope this might be of help.

Upvotes: 2

Related Questions