Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

unwrap the angle code

Asked by Niraj

Niraj (view profile)

on 15 Nov 2012

Hi, I have a vector of angles which are in the range of -360 to 360. I need to unwrap them. I donot have the wrap and unwrap built in function in my old version of MATLAB.

Could any one come up with a small piece of code to unwrap manually?

Thanks please reply.



Niraj (view profile)



No products are associated with this question.

1 Answer

Answer by C.J. Harris

C.J. Harris (view profile)

on 15 Nov 2012

Going from a range of -360 to 360 degrees to 0 to 360 degrees is usually called wrapping the angle, not unwrapping. This anonymous function should do the trick:

wrap = @(x)mod(x,360);


nAngle = -270;
ans =

1 Comment


Niraj (view profile)

on 23 Nov 2012

Thanks for the answer and correcting me..

C.J. Harris

C.J. Harris (view profile)

Contact us