regarding phase compensation?
19 次查看(过去 30 天)
显示 更早的评论
Hello,
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;
t=(0:1000)/1000;
freq = 20;
s1 = sin(2*pi*freq*t);
s2 = sin(2*pi*freq*t + theta);
theta_estimate = acos( 2*mean( s1.*s2) );
s3=s2*(cos(theta_estimate)+(1i*sin(theta_estimate)));
s3 and s1 are not completely phase synced.
0 个评论
采纳的回答
Soumya Saxena
2016-12-29
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;
t=(0:1000)/fs;
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
figure
plot(t,s1,'r*')
hold on
plot(t+time_shift_num,real(s3p),'b--')
The plots should not have phase shift between them now.
0 个评论
更多回答(1 个)
BRIAN PENG
2021-12-13
Hello, sir, in the code above:
- 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!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!