Set MATLAB Axis Range
In MATLAB, you can use the functions xlim and ylim to set the range of the coordinate axes. For example:
% 设置x轴范围为0到10,y轴范围为-5到5
xlim([0, 10]);
ylim([-5, 5]);
You can also use the axis function to set the range of the coordinate axis, the syntax format is as follows:
% 设置x轴范围为0到10,y轴范围为-5到5
axis([0, 10, -5, 5]);
Additionally, you can also directly specify the range of the axes when drawing, for example:
% 绘制曲线
x = 0:0.1:10;
y = sin(x);
plot(x, y);
% 设置x轴范围为0到10,y轴范围为-1到1
xlim([0, 10]);
ylim([-1, 1]);