rotarrow.m

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

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

⌨️ 快捷键说明

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