% YWIN - Window the y-axis limits on all axes in current figure.
%    See XWIN for calling syntax and return values
%
%    B. A. Moran, 03-Feb-1998

%    Copyright (C) 1995-1998
%    Massachussetts Institute of Technology
%    Sea Grant AUV Laboratory
%    $Id: ywin.m,v 1.1 2000/01/10 19:08:48 rob Exp $	

function lim = ywin( ylim )

if nargin < 1
    ylim = ginput(2);
    if ~isempty(ylim), ylim = ylim(:,2)'; end
end

if ~isempty(ylim)
    hhax = findobj( get(gcf,'children'), 'flat', 'type', 'axes' );
    if ~isempty(hhax)
	if ( isstr(ylim) & strcmp(lower(ylim),'full') )
	    set( hhax, 'YLimMode', 'auto' );
	    ylim = get( hhax(1), 'YLim' );
	else
	    set( hhax, 'YLim', sort(ylim) );
	end
    end

end

if nargout > 0
    lim = ylim;
end
