Wrapping an angle
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!