Using the cpsd function
조회 수: 15 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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
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 Center 및 File Exchange에서 Signal Generation and Preprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!