vecarrow.m

来自「关于电机的.m程序」· M 代码 · 共 17 行

M
17
字号
function vecarrow(A,B,colorspec) 
  % plots a colored line vector in 2D with arrow at terminus
  % A specifies the coordinates of the starting point, B the coordinates of the terminus point
  % colorspec='k|r|b|g|y|m|c' or colorspec=[RGB value]
  % written by M.Riaz
x=[A(1) B(1)];
y=[A(2) B(2)];
line(x,y,'color',colorspec);
ax=axis;
qx=(ax(2)-ax(1))*.05;
qy=(ax(4)-ax(3))*.015;
phi=180/pi*(atan2(B(2)-A(2),B(1)-A(1)));
h0=patch([B(1)-qx B(1) B(1)-qx],[B(2)+qy B(2) B(2)-qy],colorspec,'edgecolor',colorspec);
rotate(h0,[B(1) B(2) 500],phi,[B(1) B(2) 0]);
axis equal;
%

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?