regarding phase compensation?

32 views (last 30 days)
Sanjoy Basak
Sanjoy Basak on 26 Dec 2016
Answered: BRIAN PENG on 13 Dec 2021
I am trying to do simple phase compensation. However, the code is always making some extra phase correction. Its not making an exact compensation. Please have a look at the code. I think I am formulating it wrongly. Although theta estimation is pretty correct.
theta = pi/5;
freq = 20;
s1 = sin(2*pi*freq*t);
s2 = sin(2*pi*freq*t + theta);
theta_estimate = acos( 2*mean( s1.*s2) );
s3 and s1 are not completely phase synced.

Accepted Answer

Soumya Saxena
Soumya Saxena on 29 Dec 2016
I understand that you are trying to do phase compensation. Please note that a shift in time domain is equivalent to multiplication in frequency domain.
The value of 'theta_estimate" seems to be accurate.
However, one way to perform phase synchronization is to take the Fourier transform of the signal s2, and store it in S2. In the frequency domain, we can multiply S2 with exp(-theta_estimate*i/length(S2)). This is equivalent to shifting the phase of s2 by theta_estimate. We can then obtain the inverse Fourier transform of this product.
Please refer to the following code snippet:
theta = pi/5;
fs = 1000;
freq = 20;
s1 = sin(2*pi*freq*t);
s2 = sin(2*pi*freq*t + theta);
theta_estimate = acos( 2*mean( s1.*s2) );
%Calculate fft of s2
S2 = fft(s2);
% Multiplication in frequency domain means, shift by "theta_estimate" in time domain. This will
% subtract "theta_estimate" from s2.
S3 = S2.*exp(-i*theta_estimate/(length(S2)));
% Take inverse fft to get signal in time domain
s3p = ifft(S3);
%Calculate the time shift
time_shift_num = theta_estimate/(2*pi*freq)
% Plot both the signals
hold on
The plots should not have phase shift between them now.

More Answers (1)

BRIAN PENG on 13 Dec 2021
Hello, sir, in the code above:
  1. S3 = S2.*exp(-i*theta_estimate/(length(S2)));
Why we have to divide it by length(S2)?
2. plot(t+time_shift_num,real(s3p),'b--')
Why we have to add "time_shift_num" to do phase shift since suppose we have done the phase shift
in frequence already [S3 = S2.*exp(-i*theta_estimate/(length(S2)));]
3. It seems the phase shift is compensated by time shift, not frequency multiplication. Can you share articles or documentation on this?
Thank you!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by