How to extract the constant phase of a sine wave?
9 views (last 30 days)
Show older comments
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?
0 Comments
Answers (2)
Honglei Chen
on 7 Nov 2017
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
0 Comments
David Sziroczak
on 9 Nov 2017
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
0 Comments
See Also
Categories
Find more on Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!