To change the range of the x-axis or y-axis of a plot in MATLAB, you can use the xlim
or ylim
functions, respectively.
For example, if you have a line plot plot(x, y)
and you want to change the x-axis range to be from 0 to 10, you can use the following command:
main.m15 chars2 lines
Similarly, if you want to change the y-axis range to be from -5 to 5, you can use:
main.m15 chars2 lines
If you need to change both x-axis and y-axis range at the same time on a single plot, you can use the function axis([xmin, xmax, ymin, ymax])
. For example:
main.m25 chars2 lines
This command will set the x-axis range to be from -5 to 15 and y-axis range to be from -10 to 10.
gistlibby LogSnag