function yawplot( time, c_yaw, t_yaw, m_yaw, c_rudder, m_rudder, pos )
%YAWPLOT      Plot yaws and rudder activity.
%   YAWPLOT(TIME, C_YAW, T_YAW, M_YAW, C_RUDDER, M_RUDDER, POS ) plots
%   commanded & measured headings in the top window and commanded &
%   measured rudder angles in the bottom window.  POS is an optional
%   string argument specifying the position of the window on the
%   screen.
%
%   See also WINPOS.

%----------------------------------------------------------------------
%			  Copyright (C) 1995
%		Massachussetts Institute of Technology
%	       Sea Grant Underwater Vehicles Laboratory
%----------------------------------------------------------------------
%     $Revision: 1.1 $			$State: Exp $
%     $Date: 2000/01/10 19:08:47 $
%----------------------------------------------------------------------

global run_name;

if ( nargin < 6 ), error('too few arguments'); end
if ( nargin > 6 ), winpos( pos ); end

rows = 1:length(time);
if diff(c_yaw(1:2)) > .5
    rows(1) = [];
end

c_yaw = mod360( 180/pi*c_yaw );

set( gcf, 'name', 'Yaw Plots' );

subplot( 2, 1, 1 )              % commanded & measured heading
cla
[xx,yy] = stairs( time(rows), c_yaw(rows) );
plot( time(rows), 180/pi*m_yaw(rows), 'm', xx, yy, 'c' );
if ~isempty(t_yaw)
    [xx,yy] = stairs( time(rows), t_yaw(rows) );
    line( xx, 180/pi*yy, 'Color', 'g' );
end
set( gca, 'fontsize', 10, 'xgrid', 'on', 'ygrid', 'on' );
title( ['Commanded and Measured Heading: ' run_name] );
xlabel( 'mission time (s)' );
ylabel( 'heading (deg)' );
zoom on

subplot( 2, 1, 2 )              % rudder position
cla
[xx, yy] = stairs( time(rows), 180/pi*c_rudder(rows) );
plot( xx, yy, 'c', time(rows), 180/pi*m_rudder(rows), 'm' );
ylim = get(gca, 'YLim');
ylim(1) = max(ylim(1),-40); ylim(2) = min(ylim(2),40);
set( gca, 'fontsize', 10, 'XGrid', 'on', 'YLim', ylim, 'YGrid', 'on' );
title( 'Commanded and Measured Rudder Angle' );
xlabel( 'mission time (s)' );
ylabel( 'port rudder (deg)' );
zoom on
