MATLAB: Is it possible to add a function in MATLAB that automatically wraps the data to a certain range of values

MATLABwrap

I am trying to plot angles and would like to have a function that automatically wraps my data to a certain range of values.
For example, if I want my angles to be in the range of between -180 to 180 degrees, then I would like the angle -220 degrees to be converted to 140 degrees.

Best Answer

The ability to automatically convert a number to wrap around a certain range of values is not available as a built-in function in MATLAB 7.6 (R2008a).
However, the following wrapping functions are available in the Mapping Toolbox:
WRAPTO2PI
WRAPTO60
WRAPTO180
WRAPTOPI
These functions make use of the MOD function and some logical operations to achieve the described conversion.