www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ODE15sEvaluateAndExtendSolutionStructureExample.m
%% Evaluate and Extend Solution Structure % The van der Pol equation is a second order ODE % % $$y''_1 - \mu \left( 1 - y_1^2\right) y'_1+y_1=0.$$ % %% % Solve the van der Pol equation with $\mu = 1000$ using |ode15s|. The % function |vdp1000.m| ships with MATLAB(R) and encodes the equations. % Specify a single output to return a structure containing information % about the solution, such as the solver and evaluation points. tspan = [0 3000]; y0 = [2 0]; sol = ode15s(@vdp1000,tspan,y0) %% % Use |linspace| to generate 2500 points in the interval |[0 3000]|. % Evaluate the first component of the solution at these points using % |deval|. x = linspace(0,3000,2500); y = deval(sol,x,1); %% % Plot the solution. plot(x,y) %% % Extend the solution to $t_f = 4000$ using |odextend| and add the result % to the original plot. tf = 4000; sol_new = odextend(sol,@vdp1000,tf); x = linspace(3000,tf,350); y = deval(sol_new,x,1); hold on plot(x,y,'r')