%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PURPOSE: Plot range and computed altitude.
% AUTHOR:  rsm, following MIT code.
% DATE:    00/1/5
% MODS:
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
global titleStr;
global vehicleName;

 if exist( 'h_alt' ) ~= 1
   h_alt = figure;
 else  
   figure( h_alt );
 end

 set( gcf, 'name', [vehicleName,' Altimeter'] );

%mask = find( alt_m > 0 & alt_m < 99 );
%if exist( 'medfilt1' ) == 2 & ~isempty(mask)
%    alt_c = medfilt1( alt_m(mask), 5 );
%else
%    alt_c = alt_m(mask);
%end


winpos( position(1,:) );

subplot( 2, 1, 1 )

time = dataNav(:,1);
plot( time, dataNav(:,mDepth), 'm', ...
             time, dataNav(:,mDepth) + dataNav(:,mAltitude), 'b' );
area(time, dataNav(:,mDepth) + dataNav(:,mAltitude), ...
      'facecolor', [0 .75 .85]);
%     'facecolor', [0 .75 .5] );
set( gca, 'YDir', 'reverse' );
xlim = get(gca,'XLim');
line( time, dataNav(:,mDepth), 'color', [1 0.5 0], 'linewidth', 2 );
title( ['Measured Depth and Calculated Bottom: ' titleStr] );
ylabel( 'Depth, Meters' );
zoom on
grid on

subplot( 2, 1, 2 )
plot( time, dataNav(:,mPsaRange));
title( 'Raw PSA Range' );
xlabel( 'Elapsed Time, Sec.' );
ylabel( 'Range, Meters' );
set(gca,'XLim',xlim);
zoom on
grid on