
The ODEsolvers handle more general problems y′ = f ( t, y ), or problemsthat involve a mass matrix M(t, y) y′ = f(t, y).
Troubleshooting15-50Initial Value Problems for ODEs and DAEsGeneral ODE Solver QuestionsQuestionAnswerHow do the ODE solversdiffer from quad or quadl?quad and quadl solve problems of the form y′ = f ( t ). Problem size, memory use, and computation speed. The 'MassSingular' property% is left at its default 'maybe' to test the automatic detection% of a DAE.options = odeset('Mass',M,'RelTol',1e-4.'AbsTol',’Vectorized','on') = 1e4*y(:,2) semilogx(t,y) ylabel('1e4 * y(:,2)') title() xlabel('This is equivalent to the stiff ODEs coded in HB1ODE.') % -15-4915Differential Equationsfunction out = f(t,y)out = Robertson DAE problem with a Conservation Law, solved by ODE15S10.90.80.71e4 * y(:,2)0.60.50.40.30.20.10−610−410−202410101010This is equivalent to the stiff ODEs coded in HB1ODE.610810Questions and Answers, and TroubleshootingThis section contains a number of tables that answer questions about the useand operation of the MATLAB ODE solvers: Uses a logarithmic scale to plot the solution on the long time interval.function hb1dae%HB1DAE Stiff differential-algebraic equation (DAE)% A constant, singular mass matrixM = % Use an inconsistent initial condition to test initialization.y0 = tspan = % Use the LSODI example tolerances. Multiplies y 2 by 104 to make y 2 visible when plotting it with the rest of thesolution. Specifies additional points at which the solution is computed to more clearlyshow the behavior of y 2.
This is because y 2 is much smaller than the other componentsand its major change takes place in a relatively short time.
Imposes a much smaller absolute error tolerance on y 2 than on the othercomponents. Note that hb1dae:15-48Initial Value Problems for ODEs and DAEs Otherwise, type hb1dae at the command line. Similarly,although consistent initial conditions are obvious, the example uses an–3inconsistent value y 3(0) = 10 to illustrate computation of consistent initialconditions.To run this example from the MATLAB Help browser, click on the examplename. Thesolver must recognize that the problem is a DAE, not an ODE.
The problem has the form of My′ = f ( t, y ) withM =1 0 00 1 00 0 0M is obviously singular, but hb1dae does not inform the solver of this.
These differential equations satisfy a linearconservation law that is used to reformulate the problem as the DAE4y′1 = – 0.04 y 1 + 10 y 2 y 347 2y′2 = 0.04y 1 – 10 y 2 y 3 – 3 ⋅ 10 y 20 = y1 + y2 + 圓 – 1Obviously these equations do not have a solution for y ( 0 ) with componentsthat do not sum to 1. In hb1ode, the problem is solved with initial conditions y 1(0) = 1, y 2(0) = 0 ,y 3(0) = 0 to steady state. The Robertson problem coded in hb1ode is a classic testproblem for codes that solve stiff ODEs.15-4715Differential Equations4y′1 = – 0.04 y 1 + 10 y 2 y 37 24y′2 = 0.04y 1 – 10 y 2 y 3 – 3 ⋅ 10 y 27 2y′3 = 3 ⋅ 10 y 2Note The Robertson problem appears as an example in the prolog toLSODI.