Normalize FFT Signal of ECG data
Show older comments
Hi all,
I have some excel data that plots an ECG. I have the mean and performed an FFT on the data. Now I'm trying to normalize the FFT signal so I can find the magnitude and phase of each harmonic. I've looked around and have tried various ways to normalize the signal and none of my techniques seem to working. Any help would be appreciated!
Answers (1)
dpb
on 17 Apr 2018
1 vote
<FFT Example> illustrates normalization of one-sided PSD to retrieve input magnitude. Is exact for noiseless signals that match the frequency binning; real world signals have noise and energy-smearing across bins that makes for messiness, but that's the basis for where the energy is in the output signal.
8 Comments
Christopher Houk
on 18 Apr 2018
dpb
on 19 Apr 2018
What are you actually trying to normalize? "Show your work..." :)
Christopher Houk
on 19 Apr 2018
Edited: Christopher Houk
on 19 Apr 2018
What do you think the mean(y) is?
The normalization is 1/N for FFT length of the signal; if augment to nextpow2() then must account for that factor as the additional introduced points in the time signal are all zero so the power is actually only in the original N points.
Again, the example to illustrate for clean signal at a given sampling frequency to be on the bin center; noise and being off-center will effect results in the real world.
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % time vector
S = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t); % two-component clean signal
YS=fft(S); % FFT of S
P2=abs(YS/L); % PSD, ML FFT is 2-sided
P1=P2(1:L/2+1); % Get the positive one-sided components
P1(2:end-1)=2*P1(2:end-1); % half original energy each half
plot(f,P1)
produces

which reproduces the input signal magnitude of the two frequencies exactly since they are at even frequencies in the sampling rate.
NB: the normalization-by-2 factor is applied to only indices (2:end-1) because there is only one DC and one Fmax component in the returned FFT two-sided vector; doubling (1:end) would double those two unique values as well. If there's significant DC or happens to be energy content of significance in the input signal near/at the Fmax value (probably then undersampled), those will be doubled and distort the result noticeably. If the signal is band-limited and the DC component removed before the FFT, it'll never be noticed in all likelihood.
Christopher Houk
on 19 Apr 2018
Note that for most real-world cases the sampling frequency and the signal content won't match up 1:1 as they do in the above made-up example; then to estimate the total energy one must integrate over the peak instead of just using the maximum point value.
Second, noise also corrupts things; if one has sufficient data, instead of using the whole time series in a point estimate, use sections and average; noise will average out while the deterministic components will be consistent and can thus improve the estimate; sometimes dramatically.
John Navarro
on 6 May 2020
Very good explaination.
But what about the PSD?
Please notice the amplitude values will change as a function of the L value.
Notice when only L=3000 the PSD will shows the energy of 1 and 0.7 respectively, with other values the amplitude of the figure changes. Any recommendation about how to noralize this one?
%PSD
[SignalSpectrum,SignalFrequencies] = periodogram(S, ...
[],[],Fs);
plot(SignalFrequencies,SignalSpectrum)
title('PSD1')
dpb
on 6 May 2020
I'm not sure otomh what the MATLAB periodogram function does internally and don't have the time to research it just at the moment, sorry.
As noted above, the normalization of PSD via FFT uses L, the length of the input signal irrespective of N, the number of elements in the FFT if augment to nextpow2(). The extra points don't have any power associated with them so they're not included in the divisor.
I would presume periodogram would act similarly, but that is a presumption, granted.
Categories
Find more on Spectral Estimation 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!