Issue with FFT/Power Spectral Density
古いコメントを表示
Can someone explain what I'm doing wrong here? I wanna evaluate the PSD of ECG data (electrocardiogram), but I end up with this enormous peak in the fourier domain that I don't know what to do with. Where does this come from? What to do about it?
clear
load ecg_stress_test.mat
n=length(ecg_data);
fhat=fft(ecg_data,n);
PSD=fhat.*conj(fhat)/n;
figure
subplot(2,1,1), plot(ecg_data), xlim([0 length(ecg_data)])
subplot(2,1,2), plot(PSD), xlim([0 length(PSD)])
採用された回答
その他の回答 (1 件)
Paul
2021 年 11 月 4 日
That peak is at dc because the mean of the data is very large. Try
fhat=fft(detrend(ecg_data),n);
to take out the mean before taking the fft.
6 件のコメント
Sebastian Daneli
2021 年 11 月 4 日
What do you see for
sum(detrend(ecg_data))
and what is the index of PSD wher you see the spike?
Sebastian Daneli
2021 年 11 月 4 日
Hmm. My understanding of what should happen is:
n=length(ecg_data);
fhat=fft(detrend(ecg_data),n);
At this point we should have
fhat(1) == sum(detrend(ecg_data)) % to within rounding errors
What do you see for fhat(1) and sum(detrend(ecg_data)) ?
PSD=fhat.*conj(fhat)/n;
So you should see
PSD(1) == fhat(1)^2/n ;
Can you run this exact code and show the results:
clear
load ecg_stress_test.mat
whos ecgdata
n=length(ecg_data);
fhat=fft(detrend(ecg_data),n);
[fhat(1) sum(detrend(ecg_data))]
PSD=fhat.*conj(fhat)/n;
[PSD(1) fhat(1).^2/n]
Sebastian Daneli
2021 年 11 月 5 日
Paul
2021 年 11 月 8 日
I was confused abou the use of detrend. It should have been
fhat = fhat=fft(detrend(ecg_data,'constant'),n);
to subtract the mean.
カテゴリ
ヘルプ センター および File Exchange で Parametric Spectral Estimation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


