function cycleplot( time, pos )
%CYCLEPLOT      Plots timing information for control cycles.
%   CYCLEPLOT(TIME, POS) plots elapsed time in the top window and the
%   duration of each control cycle 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 $
%     $Author: rob $            $Date: 2000/01/10 19:07:49 $
%----------------------------------------------------------------------

global run_name;

if ( nargin > 1 ), winpos( pos ); end

set( gcf, 'name', 'Control Cycle Plots' );

subplot( 2, 1, 1 )                      % elapsed time
plot(time);
title( ['Elapsed Time v. Control Cycle: ' run_name] );
ylabel( 'time (s)' );
xlabel( 'control cycle' );
grid on

subplot( 2, 1, 2 )                      % cycle duration
m = size( time, 1 );
plot( time( 2:m-1 ) - time( 1:m-2 ) );
title( 'Duration of Each Cycle' );
ylabel('duration (s)');
xlabel('control cycle');
grid on

return;
