www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ODE23WithSingleSolutionComponentExample.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' = 2t.$$ % % Use a time interval of |[0,5]| and the initial condition |y0 = 0|. tspan = [0 5]; y0 = 0; [t,y] = ode23(@(t,y) 2*t, tspan, y0); %% % Plot the solution. plot(t,y,'-o')