Wrapping an angle
9 views (last 30 days)
Show older comments
Where v is a vector between -1 and +1
I say
phi = acos(v); %returns phi varying 0->pi
I have also read: http://en.wikipedia.org/wiki/Inverse_trigonometric_functions#General_solutions and understand that acos is symmetrical in the range [-pi pi]. I merely want to view the transistion across 2pi in one montonic sweep.
I wish to view phi varying between -pi and +pi (as per angle.m returns). ie I wish to see the phase increase from 0% to 100% over the course of a full oscillation, when plotted against time.
When I try
phi2 = wrapToPi(phi);
or
phi2 = wrapToPi(nancumsum(phi));
where
function a1 = wrapToPi(a0)
num2pi = floor(a0/(2*pi) + 0.5);
a1 = a0 - num2pi*2*pi;
end
I get junk answers.
Can anyone help me out? thanks
0 Comments
Accepted Answer
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!