function ship = ship_nav(fix);
%--------------------------------------------------------------------------
% SYNOPSIS
%
%   ship = ship_nav(fix)
%
% DESCRIPTION
%
%   Calculate ship speed from position fixes. FIX is a matrix with the
%   following columns:
%
%      1. time in decimal days
%      2. longitude
%      3. latitude
%
%   SHIP has columns
%
%      1. time in decimal days
%      2. ship eastward velocity  (m/s)
%      3. ship northward velocity (m/s)
%
%   Time in ship velocity is averaged over time intervals
%
%--------------------------------------------------------------------------

% Calculate ship speed
ii   = 2:size(fix,1);
dfix = fix(ii,:) - fix(ii-1,:);
afix = 0.5 * (fix(ii,:) + fix(ii-1,:));

dx   = lon_to_m(dfix(:,2), afix(:,3));
dy   = lat_to_m(dfix(:,3), afix(:,3));

ship = [ afix(:,1), dx ./ (86400*dfix(:,1)), dy ./ (86400*dfix(:,1)) ];

return;






