www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ODE23tWithSingleSolutionComponentExample.m

    %% ODE With Single Solution Component
% Simple ODEs that have a single solution component can be specified as an
% anonymous function in the call to the solver. The anonymous function must
% accept two inputs |(t,y)| even if one of the inputs is not used.

%%
% Solve the ODE
%
% $$y' = -10t.$$
%
% Use a time interval of |[0,2]| and the initial condition |y0 = 1|.
tspan = [0 2];
y0 = 1;
[t,y] = ode23t(@(t,y) -10*t, tspan, y0);

%%
% Plot the solution.
plot(t,y,'-o')