用MATLAB怎么画直角坐标系的坐标轴希望有图形和加箭头的坐标轴

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/04 06:53:51
用MATLAB怎么画直角坐标系的坐标轴希望有图形和加箭头的坐标轴

用MATLAB怎么画直角坐标系的坐标轴希望有图形和加箭头的坐标轴
用MATLAB怎么画直角坐标系的坐标轴
希望有图形和加箭头的坐标轴

用MATLAB怎么画直角坐标系的坐标轴希望有图形和加箭头的坐标轴
举个例子吧
x=-5:10; y=-5:10;
plot(x,y); axis off; hold on;
plot([0 0],[min(y) max(y)],'k',[min(x) max(x)],[0 0],'k');
ax=[max(x),max(x)-0.3,max(x)-0.3;0,0.2,-0.2];
fill(ax(1,:),ax(2,:),'k');
ay=[0,0.15,-0.15;max(y),max(y)-0.4,max(y)-0.4];
fill(ay(1,:),ay(2,:),'k'); hold on
for i=1:length(x)-1
    if x(i)~=0
        plot([x(i),x(i)],[0,0.1],'k'); hold on
        a=text(x(i),-0.4,num2str(x(i)));
        set(a,'HorizontalAlignment','center')
    end
    if y(i)~=0
        plot([0,0.1],[y(i),y(i)],'k'); hold on
        b=text(-0.4,y(i),num2str(y(i)));
        set(b,'HorizontalAlignment','center')
    end
end
c=text(-0.4,-0.4,num2str(0));
set(c,'HorizontalAlignment','center')