天天看點

matlab怎麼建立坐标系,如何在MatLab中畫帶箭頭的坐标系

如何在MatLab中畫帶箭頭的坐标系

%%畫線然後填充

clear;

close all;

%%

u = 1;

v = 2;

x=-3:3;

y=u * x + v;

figure; plot(x,y,'LineWidth',1.5);

hold on;

%Draw axes

plot([0 0],[min(y)-1 max(y)+1],'k',[min(x)-1 max(x)+1],[0

0],'k');

% Draw arrows

ax=[max(x)+1,max(x)+1-0.3,max(x)+1-0.3; 0,0.12,-0.12];

fill(ax(1,:),ax(2,:),'k');

ay=[0,0.08,-0.08; max(y)+1,max(y)+1-0.4,max(y)+1-0.4];

fill(ay(1,:),ay(2,:),'k');

%%

text(0.2, 5.6, 'y', 'FontName','Times New

Roman','FontAngle','Italic','FontSize',18,

'HorizontalAlignment','left')

text(3.6, -0.1, 'x','FontName','Times New

Roman','FontAngle','Italic','FontSize',18,

'VerticalAlignment','top')

axis off

print('-djpeg', 'Oxy.jpg')

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

annotation('doublearrow',[0.2 0.3],[0.5 0.6])

可以畫坐标在0-1之間的箭頭

要畫任意的箭頭,在

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8396&objectType=FILE#

點選裡面的Download Now:zip下載下傳檔案把解壓後的arrow.m放入matlab目前路徑,直接調用arrow函數即可