Why I am getting nans when calculating the PSD for a sequence of numbers?!!

조회 수: 14 (최근 30일)
Yasmin Tamimi
Yasmin Tamimi 2012년 11월 26일
Hey all,
I have a sequence of data saved in a column vector. I know that Fs = 400 Hz for the data when it was collected in time domain. I want to see the frequency component and calculate the power spectrum density. I used [Pxx,w] = pwelch(x) and all hat i'm getting is Nans in complex and real format!! x is my column vector. Where did I go wrong?!

답변 (1개)

Wayne King
Wayne King 2012년 11월 26일
편집: Wayne King 2012년 11월 26일
Is there a NaN in your data?
If you have a NaN in your data, that will create the output you describe. For example:
x = randn(1000,1);
x(100) = NaN;
[Pxx,W] = pwelch(x);
You can check for NaNs with isnan()
  댓글 수: 3
Wayne King
Wayne King 2012년 11월 26일
Yes you should, the question is what is a meaningful thing to do because the PSD estimate assumes that the data is uniformly sampled. If you just remove the NaNs that is no longer the case.
Yasmin Tamimi
Yasmin Tamimi 2012년 11월 26일
Then I shall linear interpolate the nans and then do the psd estimation.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Parametric Spectral Estimation에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by