필터 지우기
필터 지우기

Using the cpsd function

조회 수: 15 (최근 30일)
Eric
Eric 2021년 1월 15일
댓글: Bjorn Gustavsson 2021년 1월 15일
Dear everyone,
I have some data that was collected at a sampling rate of 200 sample/second. However, I want to calculated the cross-spectral density for only 20 sample (or 100 ms). Does anyone know how to use the cpsd function from MATLAB to do this?
So far, I have made this my input:
[Pxy,W] = cpsd(xdata,ydata,[],10,[],0);
But this gives me a weird values as output.
Any help is much appreciated!
Best,
Eric

답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2021년 1월 15일
Simply use the spectrogram function to calculate the spectrograms of your two time-series, something like this:
[S1,F1,T1] = spectrogram(D1,Window,Noverlap,[],Fs);
[S2,F2,T2] = spectrogram(D2,Window,Noverlap,[],Fs);
C12 = S1.*conj(S2);
xp12 = abs(C12);
That should give you the complex cross-spectra and the cross-spectral power.
20 samples are not that very many though? You might not get that great frequency-resolution on that...
HTH
  댓글 수: 2
Eric
Eric 2021년 1월 15일
Thanks for the comment!
What would you set the window length and overlap to if you want to calculate the cross-spectral density for smaller segments independently of each other?
Best,
Eric
Bjorn Gustavsson
Bjorn Gustavsson 2021년 1월 15일
You're welcome.
That is a great question - In my experience it comes down to what time and frequency-resolution you need, and the time-variations of your signal. I typically test around a bit. In most of my cases I have interest in variations that occur on "time-scales" of some 32-100 samples, for which I typically use 48 - 150 samples and 16 - 50 sample overlap, and then I live with the spectral resolution that gives me. With hanning/hamming/blackman/etc windows the samples shouldn't be too correlated. (note that this is not my field of expertise - then I'd start to talk about multi-taper something-slepian-something-advanced - but this is what I've gotten good enough results with.)

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

카테고리

Help CenterFile Exchange에서 Signal Generation and Preprocessing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by