📄 arrow.m
字号:
function arrow(start,stop,scale)% ARROW(start,stop,scale) draw a line with an arrow pointing from% start to stop% Draw a line with an arrow at the end of a line% start is the x,y point where the line starts% stop is the x,y point where the line stops% Scale is an optional argument that will scale the size of the arrows% It is assumed that the axis limits are already set% 8/4/93 Jeffery Faneuff% Copyright (c) 1988-93 by the MathWorks, Inc.if nargin==2 xl = get(gca,'xlim'); yl = get(gca,'ylim'); xd = xl(2)-xl(1); % this sets the scale for the arrow size yd = yl(2)-yl(1); % thus enabling the arrow to appear in correct scale = (xd + yd) / 2; % proportion to the current axisendhold onaxis(axis)xdif = stop(1) - start(1);ydif = stop(2) - start(2);theta = atan(ydif/xdif); % the angle has to point according to the slopeif(xdif>=0) scale = -scale;endxx = [start(1), stop(1),(stop(1)+0.02*scale*cos(theta+pi/4)),NaN,stop(1),... (stop(1)+0.02*scale*cos(theta-pi/4))]';yy = [start(2), stop(2), (stop(2)+0.02*scale*sin(theta+pi/4)),NaN,stop(2),... (stop(2)+0.02*scale*sin(theta-pi/4))]';plot(xx,yy)hold off
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -