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!