%% Change Axis Limits of Graph
% This example shows how to change the axis limits of a graph. By
% default, MATLAB(R) chooses axis limits to encompass the data plotted. 

% Copyright 2015 The MathWorks, Inc.



%% Create Simple Line Plot
% Define |x| as 200 linearly spaced values between -10 and 10. Define |y|
% as the sine of |x| with an exponentially decreasing amplitude. Create a line
% plot of the data.

x = linspace(-10,10,200); 
y = sin(4*x)./exp(x);

figure
plot(x,y)

%% Change Axis Limits
% Change the axis limits by passing to the |axis| function a four-element
% vector of the form |[xmin,xmax,ymin,ymax]|, where |xmin| and |xmax| set
% the scaling for the _x_-axis, and |ymin| and |ymax| set the scaling for
% the _y_-axis.
%
% You also can change the axis limits using the |xlim|, |ylim|, and |zlim|
% functions. The commands |xlim([xmin,xmax])| and |ylim([ymin,ymax])| produce the
% same result as |axis([xmin,xmax,ymin,ymax])|.
%
% Change the _x_-axis scaling to range from 0 to 10. Change the _y_-axis
% scaling to range from -1 to 1.

axis([0,10,-1,1])

%%


%% Use Semiautomatic Axis Limits
% Use an automatically calculated minimum _x_-axis limit by setting its
% value to |-inf|. MATLAB(R) calculates the limit based on the data. Set
% the maximum _x_-axis limit to 10, the minimum _y_-axis limit to -1, and
% the maximum _y_-axis limit to 1. 

axis([-inf,10,-1,1])

%%
% MATLAB calculates the minimum limit for the _x_-axis based
% on the data. To use an automatically calculated
% maximum limit, set the value to |inf|.

