两个都可以定义坐标轴:
xlim是用来定义x轴的,具体使用方法见matlab帮助文档
help xlim
XLIM X limits.
XL = XLIM gets the x limits of the current axes.
XLIM([XMIN XMAX]) sets the x limits.
XLMODE = XLIM('mode') gets the x limits mode.
XLIM(mode) sets the x limits mode.
(mode can be 'auto' or 'manual')
XLIM(AX,...) uses axes AX instead of current axes.
XLIM sets or gets the XLim or XLimMode property of an axes.
See also pbaspect, daspect, ylim, zlim.
axis是用来定义坐标轴的,包括x轴y轴z轴,具体使用方法见帮助文档
help axis
AXIS Control axis scaling and appearance.
AXIS([XMIN XMAX YMIN YMAX]) sets scaling for the x- and y-axes
on the current plot.
AXIS([XMIN XMAX YMIN YMAX ZMIN ZMAX]) sets the scaling for the
x-, y- and z-axes on the current 3-D plot.
AXIS([XMIN XMAX YMIN YMAX ZMIN ZMAX CMIN CMAX]) sets the
scaling for the x-, y-, z-axes and color scaling limits on
the current axis (see CAXIS).
V = AXIS returns a row vector containing the scaling for the
current plot. If the current view is 2-D, V has four
components; if it is 3-D, V has six components.
AXIS AUTO returns the axis scaling to its default, automatic
mode where, for each dimension, 'nice' limits are chosen based
on the extents of all line, surface, patch, and image children.
AXIS MANUAL freezes the scaling at the current limits, so that if
HOLD is turned on, subsequent plots will use the same limits.
AXIS TIGHT sets the axis limits to the range of the data.
AXIS FILL sets the axis limits and PlotBoxAspectRatio so that
the axis fills the position rectangle. This option only has
an effect if PlotBoxAspectRatioMode or DataAspectRatioMode are
manual.
AXIS IJ puts MATLAB into its "matrix" axes mode. The coordinate
system origin is at the upper left corner. The i axis is
vertical and is numbered from top to bottom. The j axis is
horizontal and is numbered from left to right.
AXIS XY puts MATLAB into its default "Cartesian" axes mode. The
coordinate system origin is at the lower left corner. The x
axis is horizontal and is numbered from left to right. The y
axis is vertical and is numbered from bottom to top.
AXIS EQUAL sets the aspect ratio so that equal tick mark
increments on the x-,y- and z-axis are equal in size. This
makes SPHERE(25) look like a sphere, instead of an ellipsoid.
AXIS IMAGE is the same as AXIS EQUAL except that the plot
box fits tightly around the data.
AXIS SQUARE makes the current axis box square in size.
AXIS NORMAL restores the current axis box to full size and
removes any restrictions on the scaling of the units.
This undoes the effects of AXIS SQUARE and AXIS EQUAL.
AXIS VIS3D freezes aspect ratio properties to enable rotation of
3-D objects and overrides stretch-to-fill.
AXIS OFF turns off all axis labeling, tick marks and background.
AXIS ON turns axis labeling, tick marks and background back on.
AXIS(H,...) changes the axes handles listed in vector H.
See also axes, grid, subplot, xlim, ylim, zlim.
总之,当你只需要定义x轴的坐标范围时,就用xlim,函数不涉及其他参数,比较简单好记;
当你需要同时定义x轴y轴z轴的坐标范围时,就用axis,一气呵成,比较方便。