programs_10a.m

来自「《Dynamical Systems with Applications usi」· M 代码 · 共 29 行

M
29
字号
% Chapter 10 - Limit Cycles.
% Programs_10a - Program to plot a vector field.
% This is also Program 8a.
% Save M-file as vectorfield.m.
% Copyright Birkhauser 2004. Stephen Lynch.

% See the phase protraits in the book.
function vectorfield(deqns,xval,yval,t)
if nargin==3;
    t=0;
end
m=length(xval);
n=length(yval);
x1=zeros(n,m);
y1=zeros(n,m);
for a=1:m
  for b=1:n
    pts = feval(deqns,t,[xval(a);yval(b)]);
    x1(b,a) = pts(1);
    y1(b,a) = pts(2);
  end
end
arrow=sqrt(x1.^2+y1.^2);
quiver(xval,yval,x1./arrow,y1./arrow,.4,'r');
axis tight;

% End of Programs_10a.

⌨️ 快捷键说明

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