How to extract the constant phase of a sine wave?

15 次查看(过去 30 天)
Hello, I would extract the phase of a simple signal, for example a sine wave:
phase = pi/2;
x = sin(omega*t + phase);
I tried with
P = angle(x)
but in this case, if I plot (t,P) I obtain a variable phase. I want the exact phase equal to pi/2, so a constant curve. Do you know how to do it?

回答(2 个)

Honglei Chen
Honglei Chen 2017-11-7
Do you know omega? If so, you can do something like this
fc = 10;
omega = 2*pi;
t = (0:9)/10;
p = pi/2;
x = sin(omega*t+p);
xc = hilbert(x);
xcref = hilbert(sin(omega*t));
P = mean(angle(xc.*conj(xcref)))
Here I'm using analytic signal to simplify the math a bit. you can also do it in real domain but then you need a low pass filter to remove the unwanted frequency after mixing.
HTH

David Sziroczak
David Sziroczak 2017-11-9
If it's such a simple function you are after, wouldn't it be possible just to simply extract value of the function at t=0 or pi or similar, and get the angle from asin?
Other idea, you could do a complex FFT and work it out from that?
Hope this helps,
David

类别

Help CenterFile Exchange 中查找有关 Frequency Transformations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by