next_hdg

Last updated Sun Sep 19 11:55:09 1999


Get nearest heading value

1. SYNOPSIS

rel = next_hdg(ref, hdg )

2. DESCRIPTION

This Matlab function calculates nearest heading value relative to the reference heading value ref. This function is required when calculating statistics of heading values that cross the boundary {360,0}. Its vailidity depends on the fact that the difference between both heading values is less than ±180, since the relative heading is given by the reference heading plus the heading change in the direction of the shortest angle difference.

Input parameters may be vectors of the same length to convert several heading values at once.

If heading values are stored in an array, one dimension must be of the same length as the reference values. The other dimension is assumed to be a list off successive heading values. Each of them is recalculated relatively to the previous value, the first value being calculated relatively to its corresponding reference element.

3. PARAMETERS



ref

Value for reference heading.



hdg

Value of current heading.

4. RETURNS



new

The heading calculated relatively to the reference.

5. AUTHORS

Pierre Jaccard, Geophysical Institute, University of Bergen, 1999