1 # Created by Octave 3.6.2, Sun Aug 05 21:39:02 2012 UTC <root@t61>
13 # name: <cell-element>
17 -- Function File: A = bvp4c (ODEFUN, BCFUN, SOLINIT)
18 Solves the first order system of non-linear differential equations
19 defined by ODEFUN with the boundary conditions defined in BCFUN.
21 The structure SOLINIT defines the grid on which to compute the
22 solution (SOLINIT.X), and an initial guess for the solution
23 (SOLINIT.Y). The output SOL is also a structure with the
25 * SOL.X list of points where the solution is evaluated
27 * SOL.Y solution evaluated at the points SOL.X
29 * SOL.YP derivative of the solution evaluated at the points
32 * SOL.SOLVER = "bvp4c" for compatibility
40 # name: <cell-element>
44 Solves the first order system of non-linear differential equations
49 # name: <cell-element>
56 # name: <cell-element>
60 -- Function File: [] = ode23 (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2,
62 -- Command: [SOL] = ode23 (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2, ...])
63 -- Command: [T, Y, [XE, YE, IE]] = ode23 (@FUN, SLOT, INIT, [OPT],
65 This function file can be used to solve a set of non-stiff
66 ordinary differential equations (non-stiff ODEs) or non-stiff
67 differential algebraic equations (non-stiff DAEs) with the well
68 known explicit Runge-Kutta method of order (2,3).
70 If this function is called with no return argument then plot the
71 solution over time in a figure window while solving the set of
72 ODEs that are defined in a function and specified by the function
73 handle @FUN. The second input argument SLOT is a double vector
74 that defines the time slot, INIT is a double vector that defines
75 the initial values of the states, OPT can optionally be a
76 structure array that keeps the options created with the command
77 `odeset' and PAR1, PAR2, ... can optionally be other input
78 arguments of any type that have to be passed to the function
81 If this function is called with one return argument then return
82 the solution SOL of type structure array after solving the set of
83 ODEs. The solution SOL has the fields X of type double column
84 vector for the steps chosen by the solver, Y of type double column
85 vector for the solutions at each time step of X, SOLVER of type
86 string for the solver name and optionally the extended time stamp
87 information XE, the extended solution information YE and the
88 extended index information IE all of type double column vector
89 that keep the informations of the event function if an event
90 function handle is set in the option argument OPT.
92 If this function is called with more than one return argument then
93 return the time stamps T, the solution values Y and optionally the
94 extended time stamp information XE, the extended solution
95 information YE and the extended index information IE all of type
98 For example, solve an anonymous implementation of the Van der Pol
101 fvdb = @(vt,vy) [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
103 vopt = odeset ("RelTol", 1e-3, "AbsTol", 1e-3, \
104 "NormControl", "on", "OutputFcn", @odeplot);
105 ode23 (fvdb, [0 20], [2 0], vopt);
112 # name: <cell-element>
116 This function file can be used to solve a set of non-stiff ordinary
121 # name: <cell-element>
128 # name: <cell-element>
132 -- Function File: [] = ode23d (@FUN, SLOT, INIT, LAGS, HIST, [OPT],
134 -- Command: [SOL] = ode23d (@FUN, SLOT, INIT, LAGS, HIST, [OPT],
136 -- Command: [T, Y, [XE, YE, IE]] = ode23d (@FUN, SLOT, INIT, LAGS,
137 HIST, [OPT], [PAR1, PAR2, ...])
138 This function file can be used to solve a set of non-stiff delay
139 differential equations (non-stiff DDEs) with a modified version of
140 the well known explicit Runge-Kutta method of order (2,3).
142 If this function is called with no return argument then plot the
143 solution over time in a figure window while solving the set of
144 DDEs that are defined in a function and specified by the function
145 handle @FUN. The second input argument SLOT is a double vector
146 that defines the time slot, INIT is a double vector that defines
147 the initial values of the states, LAGS is a double vector that
148 describes the lags of time, HIST is a double matrix and describes
149 the history of the DDEs, OPT can optionally be a structure array
150 that keeps the options created with the command `odeset' and PAR1,
151 PAR2, ... can optionally be other input arguments of any type that
152 have to be passed to the function defined by @FUN.
154 In other words, this function will solve a problem of the form
155 dy/dt = fun (t, y(t), y(t-lags(1), y(t-lags(2), ...)))
157 y(slot(1)-lags(1)) = hist(1), y(slot(1)-lags(2)) = hist(2), ...
159 If this function is called with one return argument then return
160 the solution SOL of type structure array after solving the set of
161 DDEs. The solution SOL has the fields X of type double column
162 vector for the steps chosen by the solver, Y of type double column
163 vector for the solutions at each time step of X, SOLVER of type
164 string for the solver name and optionally the extended time stamp
165 information XE, the extended solution information YE and the
166 extended index information IE all of type double column vector
167 that keep the informations of the event function if an event
168 function handle is set in the option argument OPT.
170 If this function is called with more than one return argument then
171 return the time stamps T, the solution values Y and optionally the
172 extended time stamp information XE, the extended solution
173 information YE and the extended index information IE all of type
174 double column vector.
177 - the following code solves an anonymous implementation of a
180 fcao = @(vt, vy, vz) [2 * vz / (1 + vz^9.65) - vy];
182 vopt = odeset ("NormControl", "on", "RelTol", 1e-3);
183 vsol = ode23d (fcao, [0, 100], 0.5, 2, 0.5, vopt);
185 vlag = interp1 (vsol.x, vsol.y, vsol.x - 2);
186 plot (vsol.y, vlag); legend ("fcao (t,y,z)");
188 - to solve the following problem with two delayed state
192 d y2(t)/dt = -y2(t) + y1(t-5)
193 d y3(t)/dt = -y3(t) + y2(t-10)*y1(t-10)
195 one might do the following
197 function f = fun (t, y, yd)
198 f(1) = -y(1); %% y1' = -y1(t)
199 f(2) = -y(2) + yd(1,1); %% y2' = -y2(t) + y1(t-lags(1))
200 f(3) = -y(3) + yd(2,2)*yd(1,2); %% y3' = -y3(t) + y2(t-lags(2))*y1(t-lags(2))
203 res = ode23d (@fun, T, [1;1;1], [5, 10], ones (3,2));
211 # name: <cell-element>
215 This function file can be used to solve a set of non-stiff delay
220 # name: <cell-element>
227 # name: <cell-element>
231 -- Function File: [] = ode45 (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2,
233 -- Command: [SOL] = ode45 (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2, ...])
234 -- Command: [T, Y, [XE, YE, IE]] = ode45 (@FUN, SLOT, INIT, [OPT],
236 This function file can be used to solve a set of non-stiff
237 ordinary differential equations (non-stiff ODEs) or non-stiff
238 differential algebraic equations (non-stiff DAEs) with the well
239 known explicit Runge-Kutta method of order (4,5).
241 If this function is called with no return argument then plot the
242 solution over time in a figure window while solving the set of
243 ODEs that are defined in a function and specified by the function
244 handle @FUN. The second input argument SLOT is a double vector
245 that defines the time slot, INIT is a double vector that defines
246 the initial values of the states, OPT can optionally be a
247 structure array that keeps the options created with the command
248 `odeset' and PAR1, PAR2, ... can optionally be other input
249 arguments of any type that have to be passed to the function
252 If this function is called with one return argument then return
253 the solution SOL of type structure array after solving the set of
254 ODEs. The solution SOL has the fields X of type double column
255 vector for the steps chosen by the solver, Y of type double column
256 vector for the solutions at each time step of X, SOLVER of type
257 string for the solver name and optionally the extended time stamp
258 information XE, the extended solution information YE and the
259 extended index information IE all of type double column vector
260 that keep the informations of the event function if an event
261 function handle is set in the option argument OPT.
263 If this function is called with more than one return argument then
264 return the time stamps T, the solution values Y and optionally the
265 extended time stamp information XE, the extended solution
266 information YE and the extended index information IE all of type
267 double column vector.
269 For example, solve an anonymous implementation of the Van der Pol
272 fvdb = @(vt,vy) [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
274 vopt = odeset ("RelTol", 1e-3, "AbsTol", 1e-3, \
275 "NormControl", "on", "OutputFcn", @odeplot);
276 ode45 (fvdb, [0 20], [2 0], vopt);
283 # name: <cell-element>
287 This function file can be used to solve a set of non-stiff ordinary
292 # name: <cell-element>
299 # name: <cell-element>
303 -- Function File: [] = ode45d (@FUN, SLOT, INIT, LAGS, HIST, [OPT],
305 -- Command: [SOL] = ode45d (@FUN, SLOT, INIT, LAGS, HIST, [OPT],
307 -- Command: [T, Y, [XE, YE, IE]] = ode45d (@FUN, SLOT, INIT, LAGS,
308 HIST, [OPT], [PAR1, PAR2, ...])
309 This function file can be used to solve a set of non-stiff delay
310 differential equations (non-stiff DDEs) with a modified version of
311 the well known explicit Runge-Kutta method of order (4,5).
313 If this function is called with no return argument then plot the
314 solution over time in a figure window while solving the set of
315 DDEs that are defined in a function and specified by the function
316 handle @FUN. The second input argument SLOT is a double vector
317 that defines the time slot, INIT is a double vector that defines
318 the initial values of the states, LAGS is a double vector that
319 describes the lags of time, HIST is a double matrix and describes
320 the history of the DDEs, OPT can optionally be a structure array
321 that keeps the options created with the command `odeset' and PAR1,
322 PAR2, ... can optionally be other input arguments of any type that
323 have to be passed to the function defined by @FUN.
325 In other words, this function will solve a problem of the form
326 dy/dt = fun (t, y(t), y(t-lags(1), y(t-lags(2), ...)))
328 y(slot(1)-lags(1)) = hist(1), y(slot(1)-lags(2)) = hist(2), ...
330 If this function is called with one return argument then return
331 the solution SOL of type structure array after solving the set of
332 DDEs. The solution SOL has the fields X of type double column
333 vector for the steps chosen by the solver, Y of type double column
334 vector for the solutions at each time step of X, SOLVER of type
335 string for the solver name and optionally the extended time stamp
336 information XE, the extended solution information YE and the
337 extended index information IE all of type double column vector
338 that keep the informations of the event function if an event
339 function handle is set in the option argument OPT.
341 If this function is called with more than one return argument then
342 return the time stamps T, the solution values Y and optionally the
343 extended time stamp information XE, the extended solution
344 information YE and the extended index information IE all of type
345 double column vector.
348 - the following code solves an anonymous implementation of a
351 fcao = @(vt, vy, vz) [2 * vz / (1 + vz^9.65) - vy];
353 vopt = odeset ("NormControl", "on", "RelTol", 1e-3);
354 vsol = ode45d (fcao, [0, 100], 0.5, 2, 0.5, vopt);
356 vlag = interp1 (vsol.x, vsol.y, vsol.x - 2);
357 plot (vsol.y, vlag); legend ("fcao (t,y,z)");
359 - to solve the following problem with two delayed state
363 d y2(t)/dt = -y2(t) + y1(t-5)
364 d y3(t)/dt = -y3(t) + y2(t-10)*y1(t-10)
366 one might do the following
368 function f = fun (t, y, yd)
369 f(1) = -y(1); %% y1' = -y1(t)
370 f(2) = -y(2) + yd(1,1); %% y2' = -y2(t) + y1(t-lags(1))
371 f(3) = -y(3) + yd(2,2)*yd(1,2); %% y3' = -y3(t) + y2(t-lags(2))*y1(t-lags(2))
374 res = ode45d (@fun, T, [1;1;1], [5, 10], ones (3,2));
382 # name: <cell-element>
386 This function file can be used to solve a set of non-stiff delay
391 # name: <cell-element>
398 # name: <cell-element>
402 -- Function File: [] = ode54 (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2,
404 -- Command: [SOL] = ode54 (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2, ...])
405 -- Command: [T, Y, [XE, YE, IE]] = ode54 (@FUN, SLOT, INIT, [OPT],
407 This function file can be used to solve a set of non-stiff
408 ordinary differential equations (non-stiff ODEs) or non-stiff
409 differential algebraic equations (non-stiff DAEs) with the well
410 known explicit Runge-Kutta method of order (5,4).
412 If this function is called with no return argument then plot the
413 solution over time in a figure window while solving the set of
414 ODEs that are defined in a function and specified by the function
415 handle @FUN. The second input argument SLOT is a double vector
416 that defines the time slot, INIT is a double vector that defines
417 the initial values of the states, OPT can optionally be a
418 structure array that keeps the options created with the command
419 `odeset' and PAR1, PAR2, ... can optionally be other input
420 arguments of any type that have to be passed to the function
423 If this function is called with one return argument then return
424 the solution SOL of type structure array after solving the set of
425 ODEs. The solution SOL has the fields X of type double column
426 vector for the steps chosen by the solver, Y of type double column
427 vector for the solutions at each time step of X, SOLVER of type
428 string for the solver name and optionally the extended time stamp
429 information XE, the extended solution information YE and the
430 extended index information IE all of type double column vector
431 that keep the informations of the event function if an event
432 function handle is set in the option argument OPT.
434 If this function is called with more than one return argument then
435 return the time stamps T, the solution values Y and optionally the
436 extended time stamp information XE, the extended solution
437 information YE and the extended index information IE all of type
438 double column vector.
440 For example, solve an anonymous implementation of the Van der Pol
443 fvdb = @(vt,vy) [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
445 vopt = odeset ("RelTol", 1e-3, "AbsTol", 1e-3, \
446 "NormControl", "on", "OutputFcn", @odeplot);
447 ode54 (fvdb, [0 20], [2 0], vopt);
454 # name: <cell-element>
458 This function file can be used to solve a set of non-stiff ordinary
463 # name: <cell-element>
470 # name: <cell-element>
474 -- Function File: [] = ode54d (@FUN, SLOT, INIT, LAGS, HIST, [OPT],
476 -- Command: [SOL] = ode54d (@FUN, SLOT, INIT, LAGS, HIST, [OPT],
478 -- Command: [T, Y, [XE, YE, IE]] = ode54d (@FUN, SLOT, INIT, LAGS,
479 HIST, [OPT], [PAR1, PAR2, ...])
480 This function file can be used to solve a set of non-stiff delay
481 differential equations (non-stiff DDEs) with a modified version of
482 the well known explicit Runge-Kutta method of order (2,3).
484 If this function is called with no return argument then plot the
485 solution over time in a figure window while solving the set of
486 DDEs that are defined in a function and specified by the function
487 handle @FUN. The second input argument SLOT is a double vector
488 that defines the time slot, INIT is a double vector that defines
489 the initial values of the states, LAGS is a double vector that
490 describes the lags of time, HIST is a double matrix and describes
491 the history of the DDEs, OPT can optionally be a structure array
492 that keeps the options created with the command `odeset' and PAR1,
493 PAR2, ... can optionally be other input arguments of any type that
494 have to be passed to the function defined by @FUN.
496 In other words, this function will solve a problem of the form
497 dy/dt = fun (t, y(t), y(t-lags(1), y(t-lags(2), ...)))
499 y(slot(1)-lags(1)) = hist(1), y(slot(1)-lags(2)) = hist(2), ...
501 If this function is called with one return argument then return
502 the solution SOL of type structure array after solving the set of
503 DDEs. The solution SOL has the fields X of type double column
504 vector for the steps chosen by the solver, Y of type double column
505 vector for the solutions at each time step of X, SOLVER of type
506 string for the solver name and optionally the extended time stamp
507 information XE, the extended solution information YE and the
508 extended index information IE all of type double column vector
509 that keep the informations of the event function if an event
510 function handle is set in the option argument OPT.
512 If this function is called with more than one return argument then
513 return the time stamps T, the solution values Y and optionally the
514 extended time stamp information XE, the extended solution
515 information YE and the extended index information IE all of type
516 double column vector.
519 - the following code solves an anonymous implementation of a
522 fcao = @(vt, vy, vz) [2 * vz / (1 + vz^9.65) - vy];
524 vopt = odeset ("NormControl", "on", "RelTol", 1e-3);
525 vsol = ode54d (fcao, [0, 100], 0.5, 2, 0.5, vopt);
527 vlag = interp1 (vsol.x, vsol.y, vsol.x - 2);
528 plot (vsol.y, vlag); legend ("fcao (t,y,z)");
530 - to solve the following problem with two delayed state
534 d y2(t)/dt = -y2(t) + y1(t-5)
535 d y3(t)/dt = -y3(t) + y2(t-10)*y1(t-10)
537 one might do the following
539 function f = fun (t, y, yd)
540 f(1) = -y(1); %% y1' = -y1(t)
541 f(2) = -y(2) + yd(1,1); %% y2' = -y2(t) + y1(t-lags(1))
542 f(3) = -y(3) + yd(2,2)*yd(1,2); %% y3' = -y3(t) + y2(t-lags(2))*y1(t-lags(2))
545 res = ode54d (@fun, T, [1;1;1], [5, 10], ones (3,2));
553 # name: <cell-element>
557 This function file can be used to solve a set of non-stiff delay
562 # name: <cell-element>
569 # name: <cell-element>
573 -- Function File: [] = ode78 (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2,
575 -- Command: [SOL] = ode78 (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2, ...])
576 -- Command: [T, Y, [XE, YE, IE]] = ode78 (@FUN, SLOT, INIT, [OPT],
578 This function file can be used to solve a set of non-stiff
579 ordinary differential equations (non-stiff ODEs) or non-stiff
580 differential algebraic equations (non-stiff DAEs) with the well
581 known explicit Runge-Kutta method of order (7,8).
583 If this function is called with no return argument then plot the
584 solution over time in a figure window while solving the set of
585 ODEs that are defined in a function and specified by the function
586 handle @FUN. The second input argument SLOT is a double vector
587 that defines the time slot, INIT is a double vector that defines
588 the initial values of the states, OPT can optionally be a
589 structure array that keeps the options created with the command
590 `odeset' and PAR1, PAR2, ... can optionally be other input
591 arguments of any type that have to be passed to the function
594 If this function is called with one return argument then return
595 the solution SOL of type structure array after solving the set of
596 ODEs. The solution SOL has the fields X of type double column
597 vector for the steps chosen by the solver, Y of type double column
598 vector for the solutions at each time step of X, SOLVER of type
599 string for the solver name and optionally the extended time stamp
600 information XE, the extended solution information YE and the
601 extended index information IE all of type double column vector
602 that keep the informations of the event function if an event
603 function handle is set in the option argument OPT.
605 If this function is called with more than one return argument then
606 return the time stamps T, the solution values Y and optionally the
607 extended time stamp information XE, the extended solution
608 information YE and the extended index information IE all of type
609 double column vector.
611 For example, solve an anonymous implementation of the Van der Pol
614 fvdb = @(vt,vy) [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
616 vopt = odeset ("RelTol", 1e-3, "AbsTol", 1e-3, \
617 "NormControl", "on", "OutputFcn", @odeplot);
618 ode78 (fvdb, [0 20], [2 0], vopt);
625 # name: <cell-element>
629 This function file can be used to solve a set of non-stiff ordinary
634 # name: <cell-element>
641 # name: <cell-element>
645 -- Function File: [] = ode78d (@FUN, SLOT, INIT, LAGS, HIST, [OPT],
647 -- Command: [SOL] = ode78d (@FUN, SLOT, INIT, LAGS, HIST, [OPT],
649 -- Command: [T, Y, [XE, YE, IE]] = ode78d (@FUN, SLOT, INIT, LAGS,
650 HIST, [OPT], [PAR1, PAR2, ...])
651 This function file can be used to solve a set of non-stiff delay
652 differential equations (non-stiff DDEs) with a modified version of
653 the well known explicit Runge-Kutta method of order (7,8).
655 If this function is called with no return argument then plot the
656 solution over time in a figure window while solving the set of
657 DDEs that are defined in a function and specified by the function
658 handle @FUN. The second input argument SLOT is a double vector
659 that defines the time slot, INIT is a double vector that defines
660 the initial values of the states, LAGS is a double vector that
661 describes the lags of time, HIST is a double matrix and describes
662 the history of the DDEs, OPT can optionally be a structure array
663 that keeps the options created with the command `odeset' and PAR1,
664 PAR2, ... can optionally be other input arguments of any type that
665 have to be passed to the function defined by @FUN.
667 In other words, this function will solve a problem of the form
668 dy/dt = fun (t, y(t), y(t-lags(1), y(t-lags(2), ...)))
670 y(slot(1)-lags(1)) = hist(1), y(slot(1)-lags(2)) = hist(2), ...
672 If this function is called with one return argument then return
673 the solution SOL of type structure array after solving the set of
674 DDEs. The solution SOL has the fields X of type double column
675 vector for the steps chosen by the solver, Y of type double column
676 vector for the solutions at each time step of X, SOLVER of type
677 string for the solver name and optionally the extended time stamp
678 information XE, the extended solution information YE and the
679 extended index information IE all of type double column vector
680 that keep the informations of the event function if an event
681 function handle is set in the option argument OPT.
683 If this function is called with more than one return argument then
684 return the time stamps T, the solution values Y and optionally the
685 extended time stamp information XE, the extended solution
686 information YE and the extended index information IE all of type
687 double column vector.
690 - the following code solves an anonymous implementation of a
693 fcao = @(vt, vy, vz) [2 * vz / (1 + vz^9.65) - vy];
695 vopt = odeset ("NormControl", "on", "RelTol", 1e-3);
696 vsol = ode78d (fcao, [0, 100], 0.5, 2, 0.5, vopt);
698 vlag = interp1 (vsol.x, vsol.y, vsol.x - 2);
699 plot (vsol.y, vlag); legend ("fcao (t,y,z)");
701 - to solve the following problem with two delayed state
705 d y2(t)/dt = -y2(t) + y1(t-5)
706 d y3(t)/dt = -y3(t) + y2(t-10)*y1(t-10)
708 one might do the following
710 function f = fun (t, y, yd)
711 f(1) = -y(1); %% y1' = -y1(t)
712 f(2) = -y(2) + yd(1,1); %% y2' = -y2(t) + y1(t-lags(1))
713 f(3) = -y(3) + yd(2,2)*yd(1,2); %% y3' = -y3(t) + y2(t-lags(2))*y1(t-lags(2))
716 res = ode78d (@fun, T, [1;1;1], [5, 10], ones (3,2));
724 # name: <cell-element>
728 This function file can be used to solve a set of non-stiff delay
733 # name: <cell-element>
740 # name: <cell-element>
744 -- Function File: [] = odebwe (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2,
746 -- Command: [SOL] = odebwe (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2, ...])
747 -- Command: [T, Y, [XE, YE, IE]] = odebwe (@FUN, SLOT, INIT, [OPT],
749 This function file can be used to solve a set of stiff ordinary
750 differential equations (stiff ODEs) or stiff differential
751 algebraic equations (stiff DAEs) with the Backward Euler method.
753 If this function is called with no return argument then plot the
754 solution over time in a figure window while solving the set of
755 ODEs that are defined in a function and specified by the function
756 handle @FUN. The second input argument SLOT is a double vector
757 that defines the time slot, INIT is a double vector that defines
758 the initial values of the states, OPT can optionally be a
759 structure array that keeps the options created with the command
760 `odeset' and PAR1, PAR2, ... can optionally be other input
761 arguments of any type that have to be passed to the function
764 If this function is called with one return argument then return
765 the solution SOL of type structure array after solving the set of
766 ODEs. The solution SOL has the fields X of type double column
767 vector for the steps chosen by the solver, Y of type double column
768 vector for the solutions at each time step of X, SOLVER of type
769 string for the solver name and optionally the extended time stamp
770 information XE, the extended solution information YE and the
771 extended index information IE all of type double column vector
772 that keep the informations of the event function if an event
773 function handle is set in the option argument OPT.
775 If this function is called with more than one return argument then
776 return the time stamps T, the solution values Y and optionally the
777 extended time stamp information XE, the extended solution
778 information YE and the extended index information IE all of type
779 double column vector.
781 For example, solve an anonymous implementation of the Van der Pol
784 fvdb = @(vt,vy) [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
785 vjac = @(vt,vy) [0, 1; -1 - 2 * vy(1) * vy(2), 1 - vy(1)^2];
786 vopt = odeset ("RelTol", 1e-3, "AbsTol", 1e-3, \
787 "NormControl", "on", "OutputFcn", @odeplot, \
789 odebwe (fvdb, [0 20], [2 0], vopt);
796 # name: <cell-element>
800 This function file can be used to solve a set of stiff ordinary
805 # name: <cell-element>
812 # name: <cell-element>
816 -- Function File: [] = odeexamples ()
817 Open the differential equations examples menu and allow the user
818 to select a submenu of ODE, DAE, IDE or DDE examples.
823 # name: <cell-element>
827 Open the differential equations examples menu and allow the user to
832 # name: <cell-element>
839 # name: <cell-element>
843 -- Function File: [VALUE] = odeget (ODESTRUCT, OPTION, [DEFAULT])
844 -- Command: [VALUES] = odeget (ODESTRUCT, {OPT1, OPT2, ...}, [{DEF1,
846 If this function is called with two input arguments and the first
847 input argument ODESTRUCT is of type structure array and the second
848 input argument OPTION is of type string then return the option
849 value VALUE that is specified by the option name OPTION in the
850 OdePkg option structure ODESTRUCT. Optionally if this function is
851 called with a third input argument then return the default value
852 DEFAULT if OPTION is not set in the structure ODESTRUCT.
854 If this function is called with two input arguments and the first
855 input argument ODESTRUCT is of type structure array and the second
856 input argument OPTION is of type cell array of strings then return
857 the option values VALUES that are specified by the option names
858 OPT1, OPT2, ... in the OdePkg option structure ODESTRUCT.
859 Optionally if this function is called with a third input argument
860 of type cell array then return the default value DEF1 if OPT1 is
861 not set in the structure ODESTRUCT, DEF2 if OPT2 is not set in the
862 structure ODESTRUCT, ...
864 Run examples with the command
872 # name: <cell-element>
876 If this function is called with two input arguments and the first input
881 # name: <cell-element>
888 # name: <cell-element>
892 -- Function File: [RET] = odephas2 (T, Y, FLAG)
893 Open a new figure window and plot the first result from the
894 variable Y that is of type double column vector over the second
895 result from the variable Y while solving. The types and the values
896 of the input parameter T and the output parameter RET depend on
897 the input value FLAG that is of type string. If FLAG is
899 then T must be a double column vector of length 2 with the
900 first and the last time step and nothing is returned from
904 then T must be a double scalar specifying the actual time
905 step and the return value is false (resp. value 0) for 'not
909 then T must be a double scalar specifying the last time step
910 and nothing is returned from this function.
912 This function is called by a OdePkg solver function if it was
913 specified in an OdePkg options structure with the `odeset'. This
914 function is an OdePkg internal helper function therefore it should
915 never be necessary that this function is called directly by a
916 user. There is only little error detection implemented in this
917 function file to achieve the highest performance.
919 For example, solve an anonymous implementation of the "Van der
920 Pol" equation and display the results while solving in a 2D plane
921 fvdb = @(vt,vy) [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
923 vopt = odeset ('OutputFcn', @odephas2, 'RelTol', 1e-6);
924 vsol = ode45 (fvdb, [0 20], [2 0], vopt);
931 # name: <cell-element>
935 Open a new figure window and plot the first result from the variable Y
940 # name: <cell-element>
947 # name: <cell-element>
951 -- Function File: [RET] = odephas3 (T, Y, FLAG)
952 Open a new figure window and plot the first result from the
953 variable Y that is of type double column vector over the second
954 and the third result from the variable Y while solving. The types
955 and the values of the input parameter T and the output parameter
956 RET depend on the input value FLAG that is of type string. If FLAG
959 then T must be a double column vector of length 2 with the
960 first and the last time step and nothing is returned from
964 then T must be a double scalar specifying the actual time
965 step and the return value is false (resp. value 0) for 'not
969 then T must be a double scalar specifying the last time step
970 and nothing is returned from this function.
972 This function is called by a OdePkg solver function if it was
973 specified in an OdePkg options structure with the `odeset'. This
974 function is an OdePkg internal helper function therefore it should
975 never be necessary that this function is called directly by a
976 user. There is only little error detection implemented in this
977 function file to achieve the highest performance.
979 For example, solve the "Lorenz attractor" and display the results
980 while solving in a 3D plane
981 function vyd = florenz (vt, vx)
982 vyd = [10 * (vx(2) - vx(1));
983 vx(1) * (28 - vx(3));
984 vx(1) * vx(2) - 8/3 * vx(3)];
987 vopt = odeset ('OutputFcn', @odephas3);
988 vsol = ode23 (@florenz, [0:0.01:7.5], [3 15 1], vopt);
995 # name: <cell-element>
999 Open a new figure window and plot the first result from the variable Y
1004 # name: <cell-element>
1011 # name: <cell-element>
1015 -- Function File: [] = odepkg ()
1016 OdePkg is part of the GNU Octave Repository (the Octave-Forge
1017 project). The package includes commands for setting up various
1018 options, output functions etc. before solving a set of
1019 differential equations with the solver functions that are also
1020 included. At this time OdePkg is under development with the main
1021 target to make a package that is mostly compatible to proprietary
1024 If this function is called without any input argument then open
1025 the OdePkg tutorial in the Octave window. The tutorial can also be
1026 opened with the following command
1033 # name: <cell-element>
1037 OdePkg is part of the GNU Octave Repository (the Octave-Forge project).
1041 # name: <cell-element>
1048 # name: <cell-element>
1052 -- Function File: [SOL] = odepkg_event_handle (@FUN, TIME, Y, FLAG,
1054 Return the solution of the event function that is specified as the
1055 first input argument @FUN in form of a function handle. The second
1056 input argument TIME is of type double scalar and specifies the
1057 time of the event evaluation, the third input argument Y either is
1058 of type double column vector (for ODEs and DAEs) and specifies the
1059 solutions or is of type cell array (for IDEs and DDEs) and
1060 specifies the derivatives or the history values, the third input
1061 argument FLAG is of type string and can be of the form
1063 then initialize internal persistent variables of the function
1064 `odepkg_event_handle' and return an empty cell array of size
1068 then do the evaluation of the event function and return the
1069 solution SOL as type cell array of size 4,
1072 then cleanup internal variables of the function
1073 `odepkg_event_handle' and return an empty cell array of size
1075 Optionally if further input arguments PAR1, PAR2, ... of any type
1076 are given then pass these parameters through `odepkg_event_handle'
1077 to the event function.
1079 This function is an OdePkg internal helper function therefore it
1080 should never be necessary that this function is called directly by
1081 a user. There is only little error detection implemented in this
1082 function file to achieve the highest performance.
1089 # name: <cell-element>
1093 Return the solution of the event function that is specified as the
1098 # name: <cell-element>
1105 # name: <cell-element>
1109 -- Function File: [] = odepkg_examples_dae ()
1110 Open the DAE examples menu and allow the user to select a demo
1111 that will be evaluated.
1116 # name: <cell-element>
1120 Open the DAE examples menu and allow the user to select a demo that
1125 # name: <cell-element>
1132 # name: <cell-element>
1136 -- Function File: [] = odepkg_examples_dde ()
1137 Open the DDE examples menu and allow the user to select a demo
1138 that will be evaluated.
1143 # name: <cell-element>
1147 Open the DDE examples menu and allow the user to select a demo that
1152 # name: <cell-element>
1159 # name: <cell-element>
1163 -- Function File: [] = odepkg_examples_ide ()
1164 Open the IDE examples menu and allow the user to select a demo
1165 that will be evaluated.
1170 # name: <cell-element>
1174 Open the IDE examples menu and allow the user to select a demo that
1179 # name: <cell-element>
1186 # name: <cell-element>
1190 -- Function File: [] = odepkg_examples_ode ()
1191 Open the ODE examples menu and allow the user to select a demo
1192 that will be evaluated.
1197 # name: <cell-element>
1201 Open the ODE examples menu and allow the user to select a demo that
1206 # name: <cell-element>
1210 odepkg_structure_check
1213 # name: <cell-element>
1217 -- Function File: [NEWSTRUCT] = odepkg_structure_check (OLDSTRUCT,
1219 If this function is called with one input argument of type
1220 structure array then check the field names and the field values of
1221 the OdePkg structure OLDSTRUCT and return the structure as
1222 NEWSTRUCT if no error is found. Optionally if this function is
1223 called with a second input argument "SOLVER" of type string taht
1224 specifies the name of a valid OdePkg solver then a higher level
1225 error detection is performed. The function does not modify any of
1226 the field names or field values but terminates with an error if an
1227 invalid option or value is found.
1229 This function is an OdePkg internal helper function therefore it
1230 should never be necessary that this function is called directly by
1231 a user. There is only little error detection implemented in this
1232 function file to achieve the highest performance.
1234 Run examples with the command
1235 demo odepkg_structure_check
1242 # name: <cell-element>
1246 If this function is called with one input argument of type structure
1251 # name: <cell-element>
1255 odepkg_testsuite_calcmescd
1258 # name: <cell-element>
1262 -- Function File: [MESCD] = odepkg_testsuite_calcmescd (SOLUTION,
1263 REFERENCE, ABSTOL, RELTOL)
1264 If this function is called with four input arguments of type
1265 double scalar or column vector then return a normalized value for
1266 the minimum number of correct digits MESCD that is calculated from
1267 the solution at the end of an integration interval SOLUTION and a
1268 set of reference values REFERENCE. The input arguments ABSTOL and
1269 RELTOL are used to calculate a reference solution that depends on
1270 the relative and absolute error tolerances.
1272 Run examples with the command
1273 demo odepkg_testsuite_calcmescd
1275 This function has been ported from the "Test Set for IVP solvers"
1276 which is developed by the INdAM Bari unit project group "Codes and
1277 Test Problems for Differential Equations", coordinator F. Mazzia.
1284 # name: <cell-element>
1288 If this function is called with four input arguments of type double
1293 # name: <cell-element>
1297 odepkg_testsuite_calcscd
1300 # name: <cell-element>
1304 -- Function File: [SCD] = odepkg_testsuite_calcscd (SOLUTION,
1305 REFERENCE, ABSTOL, RELTOL)
1306 If this function is called with four input arguments of type
1307 double scalar or column vector then return a normalized value for
1308 the minimum number of correct digits SCD that is calculated from
1309 the solution at the end of an integration interval SOLUTION and a
1310 set of reference values REFERENCE. The input arguments ABSTOL and
1311 RELTOL are unused but present because of compatibility to the
1312 function `odepkg_testsuite_calcmescd'.
1314 Run examples with the command
1315 demo odepkg_testsuite_calcscd
1317 This function has been ported from the "Test Set for IVP solvers"
1318 which is developed by the INdAM Bari unit project group "Codes and
1319 Test Problems for Differential Equations", coordinator F. Mazzia.
1326 # name: <cell-element>
1330 If this function is called with four input arguments of type double
1335 # name: <cell-element>
1339 odepkg_testsuite_chemakzo
1342 # name: <cell-element>
1346 -- Function File: [SOLUTION] = odepkg_testsuite_chemakzo (@SOLVER,
1348 If this function is called with two input arguments and the first
1349 input argument @SOLVER is a function handle describing an OdePkg
1350 solver and the second input argument RELTOL is a double scalar
1351 describing the relative error tolerance then return a cell array
1352 SOLUTION with performance informations about the chemical AKZO
1353 Nobel testsuite of differential algebraic equations after solving
1356 Run examples with the command
1357 demo odepkg_testsuite_chemakzo
1359 This function has been ported from the "Test Set for IVP solvers"
1360 which is developed by the INdAM Bari unit project group "Codes and
1361 Test Problems for Differential Equations", coordinator F. Mazzia.
1368 # name: <cell-element>
1372 If this function is called with two input arguments and the first input
1377 # name: <cell-element>
1381 odepkg_testsuite_hires
1384 # name: <cell-element>
1388 -- Function File: [SOLUTION] = odepkg_testsuite_hires (@SOLVER, RELTOL)
1389 If this function is called with two input arguments and the first
1390 input argument @SOLVER is a function handle describing an OdePkg
1391 solver and the second input argument RELTOL is a double scalar
1392 describing the relative error tolerance then return a cell array
1393 SOLUTION with performance informations about the HIRES testsuite
1394 of ordinary differential equations after solving (ODE-test).
1396 Run examples with the command
1397 demo odepkg_testsuite_hires
1399 This function has been ported from the "Test Set for IVP solvers"
1400 which is developed by the INdAM Bari unit project group "Codes and
1401 Test Problems for Differential Equations", coordinator F. Mazzia.
1408 # name: <cell-element>
1412 If this function is called with two input arguments and the first input
1417 # name: <cell-element>
1421 odepkg_testsuite_implakzo
1424 # name: <cell-element>
1428 -- Function File: [SOLUTION] = odepkg_testsuite_implakzo (@SOLVER,
1430 If this function is called with two input arguments and the first
1431 input argument @SOLVER is a function handle describing an OdePkg
1432 solver and the second input argument RELTOL is a double scalar
1433 describing the relative error tolerance then return a cell array
1434 SOLUTION with performance informations about the chemical AKZO
1435 Nobel testsuite of implicit differential algebraic equations after
1438 Run examples with the command
1439 demo odepkg_testsuite_implakzo
1441 This function has been ported from the "Test Set for IVP solvers"
1442 which is developed by the INdAM Bari unit project group "Codes and
1443 Test Problems for Differential Equations", coordinator F. Mazzia.
1450 # name: <cell-element>
1454 If this function is called with two input arguments and the first input
1459 # name: <cell-element>
1463 odepkg_testsuite_implrober
1466 # name: <cell-element>
1470 -- Function File: [SOLUTION] = odepkg_testsuite_implrober (@SOLVER,
1472 If this function is called with two input arguments and the first
1473 input argument @SOLVER is a function handle describing an OdePkg
1474 solver and the second input argument RELTOL is a double scalar
1475 describing the relative error tolerance then return a cell array
1476 SOLUTION with performance informations about the implicit form of
1477 the modified ROBERTSON testsuite of implicit differential
1478 algebraic equations after solving (IDE-test).
1480 Run examples with the command
1481 demo odepkg_testsuite_implrober
1483 This function has been ported from the "Test Set for IVP solvers"
1484 which is developed by the INdAM Bari unit project group "Codes and
1485 Test Problems for Differential Equations", coordinator F. Mazzia.
1492 # name: <cell-element>
1496 If this function is called with two input arguments and the first input
1501 # name: <cell-element>
1505 odepkg_testsuite_impltrans
1508 # name: <cell-element>
1512 -- Function File: [SOLUTION] = odepkg_testsuite_impltrans (@SOLVER,
1514 If this function is called with two input arguments and the first
1515 input argument @SOLVER is a function handle describing an OdePkg
1516 solver and the second input argument RELTOL is a double scalar
1517 describing the relative error tolerance then return the cell array
1518 SOLUTION with performance informations about the TRANSISTOR
1519 testsuite of implicit differential algebraic equations after
1522 Run examples with the command
1523 demo odepkg_testsuite_impltrans
1525 This function has been ported from the "Test Set for IVP solvers"
1526 which is developed by the INdAM Bari unit project group "Codes and
1527 Test Problems for Differential Equations", coordinator F. Mazzia.
1534 # name: <cell-element>
1538 If this function is called with two input arguments and the first input
1543 # name: <cell-element>
1547 odepkg_testsuite_oregonator
1550 # name: <cell-element>
1554 -- Function File: [SOLUTION] = odepkg_testsuite_oregonator (@SOLVER,
1556 If this function is called with two input arguments and the first
1557 input argument @SOLVER is a function handle describing an OdePkg
1558 solver and the second input argument RELTOL is a double scalar
1559 describing the relative error tolerance then return a cell array
1560 SOLUTION with performance informations about the OREGONATOR
1561 testsuite of ordinary differential equations after solving
1564 Run examples with the command
1565 demo odepkg_testsuite_oregonator
1567 This function has been ported from the "Test Set for IVP solvers"
1568 which is developed by the INdAM Bari unit project group "Codes and
1569 Test Problems for Differential Equations", coordinator F. Mazzia.
1576 # name: <cell-element>
1580 If this function is called with two input arguments and the first input
1585 # name: <cell-element>
1589 odepkg_testsuite_pollution
1592 # name: <cell-element>
1596 -- Function File: [SOLUTION] = odepkg_testsuite_pollution (@SOLVER,
1598 If this function is called with two input arguments and the first
1599 input argument @SOLVER is a function handle describing an OdePkg
1600 solver and the second input argument RELTOL is a double scalar
1601 describing the relative error tolerance then return the cell array
1602 SOLUTION with performance informations about the POLLUTION
1603 testsuite of ordinary differential equations after solving
1606 Run examples with the command
1607 demo odepkg_testsuite_pollution
1609 This function has been ported from the "Test Set for IVP solvers"
1610 which is developed by the INdAM Bari unit project group "Codes and
1611 Test Problems for Differential Equations", coordinator F. Mazzia.
1618 # name: <cell-element>
1622 If this function is called with two input arguments and the first input
1627 # name: <cell-element>
1631 odepkg_testsuite_robertson
1634 # name: <cell-element>
1638 -- Function File: [SOLUTION] = odepkg_testsuite_robertson (@SOLVER,
1640 If this function is called with two input arguments and the first
1641 input argument @SOLVER is a function handle describing an OdePkg
1642 solver and the second input argument RELTOL is a double scalar
1643 describing the relative error tolerance then return a cell array
1644 SOLUTION with performance informations about the modified
1645 ROBERTSON testsuite of differential algebraic equations after
1648 Run examples with the command
1649 demo odepkg_testsuite_robertson
1651 This function has been ported from the "Test Set for IVP solvers"
1652 which is developed by the INdAM Bari unit project group "Codes and
1653 Test Problems for Differential Equations", coordinator F. Mazzia.
1660 # name: <cell-element>
1664 If this function is called with two input arguments and the first input
1669 # name: <cell-element>
1673 odepkg_testsuite_transistor
1676 # name: <cell-element>
1680 -- Function File: [SOLUTION] = odepkg_testsuite_transistor (@SOLVER,
1682 If this function is called with two input arguments and the first
1683 input argument @SOLVER is a function handle describing an OdePkg
1684 solver and the second input argument RELTOL is a double scalar
1685 describing the relative error tolerance then return the cell array
1686 SOLUTION with performance informations about the TRANSISTOR
1687 testsuite of differential algebraic equations after solving
1690 Run examples with the command
1691 demo odepkg_testsuite_transistor
1693 This function has been ported from the "Test Set for IVP solvers"
1694 which is developed by the INdAM Bari unit project group "Codes and
1695 Test Problems for Differential Equations", coordinator F. Mazzia.
1702 # name: <cell-element>
1706 If this function is called with two input arguments and the first input
1711 # name: <cell-element>
1718 # name: <cell-element>
1722 -- Function File: [RET] = odeplot (T, Y, FLAG)
1723 Open a new figure window and plot the results from the variable Y
1724 of type column vector over time while solving. The types and the
1725 values of the input parameter T and the output parameter RET
1726 depend on the input value FLAG that is of type string. If FLAG is
1728 then T must be a double column vector of length 2 with the
1729 first and the last time step and nothing is returned from
1733 then T must be a double scalar specifying the actual time
1734 step and the return value is false (resp. value 0) for 'not
1738 then T must be a double scalar specifying the last time step
1739 and nothing is returned from this function.
1741 This function is called by a OdePkg solver function if it was
1742 specified in an OdePkg options structure with the `odeset'. This
1743 function is an OdePkg internal helper function therefore it should
1744 never be necessary that this function is called directly by a
1745 user. There is only little error detection implemented in this
1746 function file to achieve the highest performance.
1748 For example, solve an anonymous implementation of the "Van der
1749 Pol" equation and display the results while solving
1750 fvdb = @(vt,vy) [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
1752 vopt = odeset ('OutputFcn', @odeplot, 'RelTol', 1e-6);
1753 vsol = ode45 (fvdb, [0 20], [2 0], vopt);
1760 # name: <cell-element>
1764 Open a new figure window and plot the results from the variable Y of
1769 # name: <cell-element>
1776 # name: <cell-element>
1780 -- Function File: [RET] = odeprint (T, Y, FLAG)
1781 Display the results of the set of differential equations in the
1782 Octave window while solving. The first column of the screen output
1783 shows the actual time stamp that is given with the input arguemtn
1784 T, the following columns show the results from the function
1785 evaluation that are given by the column vector Y. The types and
1786 the values of the input parameter T and the output parameter RET
1787 depend on the input value FLAG that is of type string. If FLAG is
1789 then T must be a double column vector of length 2 with the
1790 first and the last time step and nothing is returned from
1794 then T must be a double scalar specifying the actual time
1795 step and the return value is false (resp. value 0) for 'not
1799 then T must be a double scalar specifying the last time step
1800 and nothing is returned from this function.
1802 This function is called by a OdePkg solver function if it was
1803 specified in an OdePkg options structure with the `odeset'. This
1804 function is an OdePkg internal helper function therefore it should
1805 never be necessary that this function is called directly by a
1806 user. There is only little error detection implemented in this
1807 function file to achieve the highest performance.
1809 For example, solve an anonymous implementation of the "Van der
1810 Pol" equation and print the results while solving
1811 fvdb = @(vt,vy) [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
1813 vopt = odeset ('OutputFcn', @odeprint, 'RelTol', 1e-6);
1814 vsol = ode45 (fvdb, [0 20], [2 0], vopt);
1821 # name: <cell-element>
1825 Display the results of the set of differential equations in the Octave
1830 # name: <cell-element>
1837 # name: <cell-element>
1841 -- Function File: [ODESTRUCT] = odeset ()
1842 -- Command: [ODESTRUCT] = odeset ("FIELD1", VALUE1, "FIELD2", VALUE2,
1844 -- Command: [ODESTRUCT] = odeset (OLDSTRUCT, "FIELD1", VALUE1,
1845 "FIELD2", VALUE2, ...)
1846 -- Command: [ODESTRUCT] = odeset (OLDSTRUCT, NEWSTRUCT)
1847 If this function is called without an input argument then return a
1848 new OdePkg options structure array that contains all the necessary
1849 fields and sets the values of all fields to default values.
1851 If this function is called with string input arguments "FIELD1",
1852 "FIELD2", ... identifying valid OdePkg options then return a new
1853 OdePkg options structure with all necessary fields and set the
1854 values of the fields "FIELD1", "FIELD2", ... to the values VALUE1,
1857 If this function is called with a first input argument OLDSTRUCT
1858 of type structure array then overwrite all values of the options
1859 "FIELD1", "FIELD2", ... of the structure OLDSTRUCT with new values
1860 VALUE1, VALUE2, ... and return the modified structure array.
1862 If this function is called with two input argumnets OLDSTRUCT and
1863 NEWSTRUCT of type structure array then overwrite all values in the
1864 fields from the structure OLDSTRUCT with new values of the fields
1865 from the structure NEWSTRUCT. Empty values of NEWSTRUCT will not
1866 overwrite values in OLDSTRUCT.
1868 For a detailed explanation about valid fields and field values in
1869 an OdePkg structure aaray have a look at the `odepkg.pdf', Section
1870 'ODE/DAE/IDE/DDE options' or run the command `doc odepkg' to open
1873 Run examples with the command
1881 # name: <cell-element>
1885 If this function is called without an input argument then return a new