0
votes

From my understanding, when using the cpsd function as such:

[Pxy,f] = cpsd(x,y,window,Ns,NFFT,Fs); 

matlab chops the time series data into smaller windows with size specified by you. And the windows are shifted by Ns data point. The final [Pxy, f] are an average of results obtained from each individual window. Please correct me if I am wrong about this process.

My question is, if I use angle(Pxy) at a specific frequency, say 34Hz. Does that give me the phase difference between signal x and y at the frequency 34Hz?

I am having doubt about this because if Pxy was an average between each individual window, and because each individual was offset by a window shift, doesn't that mean the averaged Pxy's phase is affected by the window shift?

I've tried to correct this by ensuring that the window shift corresponds to an integer of full phase difference corresponding to 34Hz. Is this correct?

And just a little background about what I am doing:

  • I basically have numerous time-series pressure measurement over 60 seconds at 1000Hz sampling rate.

  • Power spectrum analysis indicates that there is a peak frequency at 34 Hz for each signal. (averaged over all windows)

  • I want to compare each signal's phase difference from each other corresponding to the 34Hz peak.

  • FFT analysis of individual window reveals that this peak frequency moves around. So I am not sure if cpsd is the correct way to be going about this.

  • I am currently considering trying to use xcorr to calculate the overall time lag between the signals and then calculate the phase difference from that. I have also heard of hilbert transform, but I got no idea how that works yet.

1

1 Answers

0
votes

Yes, cpsd works. You can test your result by set two input signals, such as:

t=[0:0.001:5];
omega=25;
x1=sin(2*pi*omega*t);
x2=sin(2*pi*omega*t+pi/3);

you can check whether the phase shift calculated by cpsd is pi/3.