要用的时候总是忘记,这回给把它写在这里!
%%程序1
arg1 = 2;
arg2 = 1;
[T,Y] = ode45('vdp1000',[0 10],[2 0], [], arg1, arg2);
plot(T,Y(:,1),'-o');
%%程序2
function dy = vdp1000(t, y, flag, arg1, arg2)
dy =
zeros(2,1); %
a column vector
dy(1) = y(2);
dy(2) = arg1*(arg2 - y(1)^2)*y(2) - y(1);
%%ode5
function Y = ode5(odefun,tspan,y0,varargin)
%ODE5 Solve differential equations with a non-adaptive method of
order 5.
% Y = ODE5(ODEFUN,TSPAN,Y0) with TSPAN = [T1, T2, T3, ... TN]
integrates
% the system of differential equations y' = f(t,y) by stepping from
T0 to
% T1 to TN. Function ODEFUN(T,Y) must return f(t,y) in a column
vector.
% The vector Y0 is the initial conditions at T0. Each row in the