# Phase angle between two harmnic orders

I am trying to get the phase angle between 5th harmonic and the fundamental harmonic of a 50Hz current signal sampled @10kHz. I am doing the following:

1- take a window of 200ms and apply matlab function fft. I get here complex values.

2- Calculate the angle of every harmonic order using matlab function angle().

3- Substract 5th order phase from 1st order.

The issue is I am getting a rotating phase difference as shown below.

Is there any way I can get a non-rotating difference between the two harmonics. I understand that they are of different frequencies, but I am trying to get such angle according to IEC standard as shown below:

Edit This is a snapshot of the signal I am trying to analyse. The snapshot start from the closest point of zero crossing, the size of fft window is 200ms which is 10 times the signal frequency.

After running fft of the entier period in the snapshot, 150 fft windows could be obtained with the angles of fundamental and 5th order shown below.

Absolute phase is rarely meaningful since is it's highly dependent on your exact definition of your time reference, i.e. what exactly does $$t=0$$ mean.

Since your time reference changes from frame to frame, so does the phase.

If you know the fundamental frequency EXACTLY and it's phase locked to your sample clock, you can fix this simply by making the hop size (and the frame size) an integer multiple of the fundamental period.

If it's not phase locked, you can try lining up the start of your frames to the "best" zero crossing in your signal and get the frame length as close to an integer multiple as possible. If your signal is reasonably well behaved and fairly noise free, that should work ok.

If none of these work, ask again. There are more options, but they are also more complicated.

• Thank you for the answer (upvoted). I tried analysing the signal starting from closest zero crossing but that did not work, the phase difference is still rotating. My signal frequency is between 49.9 and 51.1, but the fft bins are 5Hz, so I think this marginal change in frequency would be covered by the wide bins. I would appreciate it if you can refere me to more complicated methods. Thank you. Feb 11, 2021 at 9:58
• If you line them properly it shouldn't rotate, or at least not much. Can you post a plot or some data of your signal ? Feb 11, 2021 at 16:31
• thank you for the follow-up. I've edited the question with the requested details. Feb 11, 2021 at 17:30