function RespObj = axeslims(RespObj)
%AXESLIMS  Sets the axes limits for Initial Condition Response Objects
%
%   RespObj = AXESLIMS(RespObj)

%   Authors: Karen Gondoly, 5-14-98
%   Revised: Adam DiVergilio, 11-99
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.14 $  $Date: 2000/07/26 21:06:04 $

AllRespProps = get(RespObj,'Undocumented');
DispAx = AllRespProps.PlotAxes;
Xlims = AllRespProps.Xlim;
Ylims = AllRespProps.Ylim;
AutoX = strcmp(AllRespProps.XlimMode,'auto');
AutoY = strcmp(AllRespProps.YlimMode,'auto');

%---Set axis lim mode
if AutoX
   set(DispAx(:),'XlimMode','auto')
end
if AutoY
   set(DispAx(:),'YlimMode','auto')
end

%---Adjust X-limits
if AutoX
	%---Enforce uniform X-axis limits across each column
	VisAx = DispAx(strcmp(get(DispAx,'Visible'),'on'),1);
	if isempty(VisAx)
		Xlims{1} = [0 1];
	else
		Xlims{1} = get(VisAx(1),'Xlim');
	end
end

%---Adjust Y-limits
if AutoY
   Ylims = get(DispAx(:,1),{'Ylim'});
end

%---Toggle grid
RespObj = plotgrid(RespObj);

% Update axis limits in RespObj
% RE: Leave XlimMode and YlimMode untouched
RespObj = respfcn('setxylims',RespObj,Xlims,Ylims);
