File Exchange

image thumbnail

Polar/cartesian into degree north reference

version 1.0 (1.85 KB) by

Set of function to convert polar/cartesian coordinates into degrees north and inversely.

5 Downloads

Updated

View License

This set of function change from polar or cartesian coordinates into degrees with north reference. It also change degrees north into cartesian or polar coordinates. This is useful when working with velocity vector, e.g. current, wind.
The functions work with single values or with vectors.

The zip file contain:

- compass2pol.m: change degree north into polar coordinates.
- compass2cart.m: change degree north and velocity into u and v (cartesian coordinates).
- cart2compass.m: change u and v (cartesian coordinates) into degree north and velocity.
- pol2compass.m: change polar coordinates into degree north.

Comments and Ratings (3)

Damien Guihen

Rather than the find, you can speed it up a bit using an index:

   degN = 90 - deg;
   idx = find(degN < 0);
   degN(idx) = degN(idx) + 360;

becomes

   degN = 90 - deg;
   degN(degN < 0) = degN + 360;

janez

janez (view profile)

cart2compass engine can be simplified - you don't need three 'find'-s.

degN: angle in degree north system (N = 0 degrees, E = 90 degrees)
deg: cartesian angle (E = 0 degrees, N = 90 degrees)

then it follows:

degN = 90 - deg;
idx = find(degN < 0);
degN(idx) = degN(idx) + 360;

output:
deg =

     0 45 90 135 180 225 270 315 360

degN =

    90 45 0 315 270 225 180 135 90

regards!

MATLAB Release
MATLAB 7.5 (R2007b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video