next_hdg(3m)

NAME
next_hdg - Get nearest heading value

SYNOPSIS
rel = next_hdg(ref, hdg )

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.

PARAMETERS

ref Value for reference heading.

hdg Value of current heading.

RETURNS

new The heading calculated relatively to the reference.

AUTHORS
Pierre Jaccard, Geophysical Institute, University of Bergen, 1999