arrow.m

来自「用matlab实现利用统计混沌方法解决非线性系统时间序列预测的问题」· M 代码 · 共 35 行

M
35
字号
function arrow(point1,point2,S,rlength,rwidth)
% The function: 
% 
%       arrow(point1,point2,S,rlength,rwidth)
% 
% draws an arrow from point <point1> to point <point2>
% in the 2-dimensional space. 
% Optional arg <S> is like in plot(X,Y,S); 
% default value is '-'.
% Optional arg <rlength> is the relative length of the 
% pointing end; default value is 0.3. 
% Optional arg <rwidth> is the relative width of the 
% pointing end; default value is 0.2. 

% args
if nargin<2, error('not enough args'); end;
if nargin<3, S = '-'; end;
if nargin<4, rlength = 0.3; end;
if nargin<5, rwidth  = 0.2; end;

% unit arrow
arrowx = [0,1,1.0-rlength,1,1.0-rlength];
arrowy = [0,0,+0.5*rwidth,0,-0.5*rwidth];

% vector
vector = point2 - point1;

% dilation, rotation & plot
if length(vector)==2,
        drot = [[+vector(1),-vector(2)];
                [+vector(2),+vector(1)]];
        arrowxy = drot*[arrowx;arrowy];
        plot(point1(1)+arrowxy(1,:),point1(2)+arrowxy(2,:),S);
end;

⌨️ 快捷键说明

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