program_8b.m

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

M
33
字号
% Chapter 8 - Planar Systems.
% Program_8b - Phase portrait (Fig. 8.8(a)).
% Copyright Birkhauser 2004. Stephen Lynch.

% Phase portrait of a linear system of ODE's.
% IMPORTANT - Save Program_8a as vectorfield.m.
clear
sys=inline('[2*x(1)+x(2);x(1)+2*x(2)]','t', 'x');
warning off MATLAB:divideByZero
vectorfield(sys,-3:.25:3,-3:.25:3)
     hold on
     for x0=-3:1.5:3
         for y0=-3:1.5:3
            [ts,xs] = ode45(sys,[0 5],[x0 y0]);
            plot(xs(:,1),xs(:,2))
         end
     end
     for x0=-3:1.5:3
         for y0=-3:1.5:3
            [ts,xs] = ode45(sys,[0 -5],[x0 y0]);
            plot(xs(:,1),xs(:,2))
         end
     end
     hold off
axis([-3 3 -3 3])
fsize=15;
set(gca,'xtick',[-3:1:3],'FontSize',fsize)
set(gca,'ytick',[-3:1:3],'FontSize',fsize)
xlabel('x(t)','FontSize',fsize)
ylabel('y(t)','FontSize',fsize)
hold off

% End of Program_8b.

⌨️ 快捷键说明

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