# Wrapping an angle

5 vues (au cours des 30 derniers jours)
Matlab2010 le 8 Juin 2012
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
Can anyone help me out? thanks
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Matlab2010 le 8 Juin 2012
phiOut = wrapToPi(nancumsum(abs(diff(phi))));
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Lengths and Angles dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by