matlab坐标轴设置:
简单的曲线:y=sin(x);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=-pi/2:0.01:pi/2;
y=sin(x);
plot(x,y);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
上面的图坐标轴默认格式,不太符合数学习惯。可以按照下面设置:
x坐标轴设置成-pi/2到pi/2,间隔为pi/4
y坐标轴设置成-1到1,间隔为0.5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Xmark=-pi/2:pi/4:pi/2; %X轴刻度
XmarkLabel={'-pi/2','-pi/4','0','pi/4','pi/2'}; %X轴刻度的标注
Ymark=-1:0.5:1; %Y轴刻度
YmarkLabel={'-1','-0.5','0','0.5','1'}; %Y轴刻度的标注
set(gca,'XTick',Xmark); %设置X轴刻度
set(gca,'XTicklabel',XmarkLabel); %设置X轴标注
set(gca,'YTick',Ymark); %设置Y轴刻度
set(gca,'YTicklabel',YmarkLabel); %设置Y轴标注
set(gca,'XGrid','on'); %打开X轴格网
set(gca,'YGrid','on'); %打开Y轴格网
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%