Matlab axis函数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/youshijian99/article/details/80842218

axis    用于操作普通的坐标属性,(轴的缩放和外观)。

axis( [xmin xmax ymin ymax] )    设置当前坐标轴 x轴 和 y轴的限制范围

axis( [xmin xmax ymin ymax zmin zmax cmin cmax] ) 设置 x,y,z轴的限制范围和色差范围。
v = axis 返回一个行向量,记录了坐标范围

axis auto 解除限制,恢复到默认状态

例程:画一个tan函数从0到2π。
>> x=0:0.01:pi/2;
>> y=tan(x);
>> figure
>> plot(x,y,'-o')


>> axis([0,pi/2,0,5])    % 改变坐标轴范围


>> v = axis    % 返回坐标轴的范围
v =    0    1.5708         0    5.0000


例程:画坐标 (需要使用arrow3函数,上网下载即可)
>> close all
>> figure
>> axis([0 4 0 5 0 6])    % 画出三维图
>> hold on
>> addpath(genpath(pwd))    % 用于扫描子目录
>> arrow3([0 0 0],[4 0 0],'g')
警告: Stretch-to-fill scaling not supported;
use DASPECT or PBASPECT before calling ARROW3. 
> In arrow3 at 397 

>> arrow3([0 0 0],[0 5 0],'r')
>> arrow3([0 0 0],[0 0 6],'e')
>> hold on 
>> arrow3([0 0 0],[3 2 4], 'b')  % 画出向量线
>> hold on
>> text(0.2,0.2,0,'O')    % 添加坐标原点名称
>> text(3,0,0,'X')
>> text(0,3,0,'Y')
>> text(0,0,3,'Z')
>> hold on
>> arrow3([3 2 4],[3.8 2 4])    % 方向轴
>> text(4,2,4,'x1')
>> arrow3([3 2 4],[3 2.8 4])
>> text(3,3,4,'y1')
>> arrow3([3 2 4],[3 2 4.8])
>> text(3,2,5,'z1')
>> hold on
>> set(gca,'XDir','reverse')  %  对 X 轴方向反转

猜你喜欢

转载自blog.csdn.net/youshijian99/article/details/80842218