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 and 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 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.