0

I have some beginner, basic Physionet data I am trying to apply FFT to, but I'm a bit confused by the results I'm getting and don't think they're correct. I'm mostly using code from this example and from the fftshift documentation page with some tweaks but I'm not too sure what's wrong with my code or results. I have attached my code and snapshots of the results I'm getting.

load aami3am.mat

Fs = 720;                    % Sampling frequency
T = 1/Fs;                    % Sample time
L = 60000;                   % Length of signal
t = (0:L-1)*T;               % Time vector


plot(t(1:43081),val(1:43081))
title('aami4b_h Signal')
xlabel('Seconds')
ylabel('ECG Amplitude')


NFFT = 2^nextpow2(L);
val = detrend(val); 
Y = fft(val,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
plot(f,2*abs(Y(1:NFFT/2+1))) 
title('FFT')


yY = fftshift(Y);
fshift = (-L/2:L/2-1)*(Fs/L);
powershift = abs(yY).^2/L;    
plot(fshift(1:L),powershift(1:L))
title('FFT Shifted')

Original signal

fft

fft shifted

I'm using 43081 because there are 43081 values in the .mat file over the 60 seconds of data.

Alex
  • 17
  • 4
  • 1
    By doing `fft(val,NFFT)` instead of `fft(val)` you are padding with zeros. This changes your data. You are also not windowing your data. Finally, I suggest that you plot your degreased data to make sure it’s correct. – Cris Luengo Jul 25 '20 at 14:49
  • I see, thanks! What exactly do you mean by plotting degreased data? I'm not exactly sure what this term means but it's probably my ignorance in this field. – Alex Jul 26 '20 at 07:22
  • That was meant to say “detrended”. I don’t know how that became “degreased” to my phone’s autocorrect. Sorry. – Cris Luengo Jul 26 '20 at 13:15

0 Answers0