Mercurial > octave
annotate scripts/ode/ode45.m @ 33625:d213a148b3f1 default tip @
ensure exp. terminal widget has focus at startup
* main-window.cc (main_window): call focus_command_window only if
event loop is idle by using a single shot timer
* main-window.h: make focus_command_window a public slot
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sun, 26 May 2024 02:29:44 +0200 |
parents | 2e484f9f1f18 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
3 ## Copyright (C) 2006-2024 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
7 ## |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22660
diff
changeset
|
13 ## (at your option) any later version. |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
14 ## |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22660
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22660
diff
changeset
|
18 ## GNU General Public License for more details. |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
19 ## |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
25 |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
27 ## @deftypefn {} {[@var{t}, @var{y}] =} ode45 (@var{fcn}, @var{trange}, @var{init}) |
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
28 ## @deftypefnx {} {[@var{t}, @var{y}] =} ode45 (@var{fcn}, @var{trange}, @var{init}, @var{ode_opt}) |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20719
diff
changeset
|
29 ## @deftypefnx {} {[@var{t}, @var{y}, @var{te}, @var{ye}, @var{ie}] =} ode45 (@dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20719
diff
changeset
|
30 ## @deftypefnx {} {@var{solution} =} ode45 (@dots{}) |
22939
54302b670139
doc: Document nargout=0 calling mode for ode23, ode45.
Rik <rik@octave.org>
parents:
22937
diff
changeset
|
31 ## @deftypefnx {} {} ode45 (@dots{}) |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
32 ## |
20548
25623ef2ff4f
doc: Rewrite docstrings for ode* family of functions.
Rik <rik@octave.org>
parents:
20543
diff
changeset
|
33 ## Solve a set of non-stiff Ordinary Differential Equations (non-stiff ODEs) |
20719
d903cccb8de8
doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents:
20634
diff
changeset
|
34 ## with the well known explicit @nospell{Dormand-Prince} method of order 4. |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
35 ## |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
36 ## @var{fcn} is a function handle, inline function, or string containing the |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
37 ## name of the function that defines the ODE: @code{y' = f(t,y)}. The function |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
38 ## must accept two inputs where the first is time @var{t} and the second is a |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
39 ## column vector of unknowns @var{y}. |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
40 ## |
20548
25623ef2ff4f
doc: Rewrite docstrings for ode* family of functions.
Rik <rik@octave.org>
parents:
20543
diff
changeset
|
41 ## @var{trange} specifies the time interval over which the ODE will be |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
42 ## evaluated. Typically, it is a two-element vector specifying the initial and |
20548
25623ef2ff4f
doc: Rewrite docstrings for ode* family of functions.
Rik <rik@octave.org>
parents:
20543
diff
changeset
|
43 ## final times (@code{[tinit, tfinal]}). If there are more than two elements |
25623ef2ff4f
doc: Rewrite docstrings for ode* family of functions.
Rik <rik@octave.org>
parents:
20543
diff
changeset
|
44 ## then the solution will also be evaluated at these intermediate time |
22594
b8d525710075
cleanup ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22593
diff
changeset
|
45 ## instances. |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
46 ## |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
47 ## By default, @code{ode45} uses an adaptive timestep with the |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
48 ## @code{integrate_adaptive} algorithm. The tolerance for the timestep |
25026
f886561f9696
doc: improve differential eqtn docs and mention ode15i/ode15s (bug #51965).
Colin Macdonald <cbm@m.fsf.org>
parents:
24534
diff
changeset
|
49 ## computation may be changed by using the options @qcode{"RelTol"} and |
f886561f9696
doc: improve differential eqtn docs and mention ode15i/ode15s (bug #51965).
Colin Macdonald <cbm@m.fsf.org>
parents:
24534
diff
changeset
|
50 ## @qcode{"AbsTol"}. |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
51 ## |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
52 ## @var{init} contains the initial value for the unknowns. If it is a row |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
53 ## vector then the solution @var{y} will be a matrix in which each column is |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
54 ## the solution for the corresponding initial value in @var{init}. |
20548
25623ef2ff4f
doc: Rewrite docstrings for ode* family of functions.
Rik <rik@octave.org>
parents:
20543
diff
changeset
|
55 ## |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
56 ## The optional fourth argument @var{ode_opt} specifies non-default options to |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
57 ## the ODE solver. It is a structure generated by @code{odeset}. |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
58 ## |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
59 ## The function typically returns two outputs. Variable @var{t} is a |
20548
25623ef2ff4f
doc: Rewrite docstrings for ode* family of functions.
Rik <rik@octave.org>
parents:
20543
diff
changeset
|
60 ## column vector and contains the times where the solution was found. The |
25623ef2ff4f
doc: Rewrite docstrings for ode* family of functions.
Rik <rik@octave.org>
parents:
20543
diff
changeset
|
61 ## output @var{y} is a matrix in which each column refers to a different |
25623ef2ff4f
doc: Rewrite docstrings for ode* family of functions.
Rik <rik@octave.org>
parents:
20543
diff
changeset
|
62 ## unknown of the problem and each row corresponds to a time in @var{t}. |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
63 ## |
25026
f886561f9696
doc: improve differential eqtn docs and mention ode15i/ode15s (bug #51965).
Colin Macdonald <cbm@m.fsf.org>
parents:
24534
diff
changeset
|
64 ## The output can also be returned as a structure @var{solution} which has a |
f886561f9696
doc: improve differential eqtn docs and mention ode15i/ode15s (bug #51965).
Colin Macdonald <cbm@m.fsf.org>
parents:
24534
diff
changeset
|
65 ## field @var{x} containing a row vector of times where the solution was |
f886561f9696
doc: improve differential eqtn docs and mention ode15i/ode15s (bug #51965).
Colin Macdonald <cbm@m.fsf.org>
parents:
24534
diff
changeset
|
66 ## evaluated and a field @var{y} containing the solution matrix such that each |
f886561f9696
doc: improve differential eqtn docs and mention ode15i/ode15s (bug #51965).
Colin Macdonald <cbm@m.fsf.org>
parents:
24534
diff
changeset
|
67 ## column corresponds to a time in @var{x}. Use |
f886561f9696
doc: improve differential eqtn docs and mention ode15i/ode15s (bug #51965).
Colin Macdonald <cbm@m.fsf.org>
parents:
24534
diff
changeset
|
68 ## @w{@code{fieldnames (@var{solution})}} to see the other fields and |
21546
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
69 ## additional information returned. |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
70 ## |
28713
28d2511f2af2
maint: grammarcheck documentation ahead of 6.1 release.
Rik <rik@octave.org>
parents:
28045
diff
changeset
|
71 ## If no output arguments are requested, and no @qcode{"OutputFcn"} is |
28d2511f2af2
maint: grammarcheck documentation ahead of 6.1 release.
Rik <rik@octave.org>
parents:
28045
diff
changeset
|
72 ## specified in @var{ode_opt}, then the @qcode{"OutputFcn"} is set to |
28d2511f2af2
maint: grammarcheck documentation ahead of 6.1 release.
Rik <rik@octave.org>
parents:
28045
diff
changeset
|
73 ## @code{odeplot} and the results of the solver are plotted immediately. |
22939
54302b670139
doc: Document nargout=0 calling mode for ode23, ode45.
Rik <rik@octave.org>
parents:
22937
diff
changeset
|
74 ## |
25026
f886561f9696
doc: improve differential eqtn docs and mention ode15i/ode15s (bug #51965).
Colin Macdonald <cbm@m.fsf.org>
parents:
24534
diff
changeset
|
75 ## If using the @qcode{"Events"} option then three additional outputs may be |
f886561f9696
doc: improve differential eqtn docs and mention ode15i/ode15s (bug #51965).
Colin Macdonald <cbm@m.fsf.org>
parents:
24534
diff
changeset
|
76 ## returned. @var{te} holds the time when an Event function returned a zero. |
f886561f9696
doc: improve differential eqtn docs and mention ode15i/ode15s (bug #51965).
Colin Macdonald <cbm@m.fsf.org>
parents:
24534
diff
changeset
|
77 ## @var{ye} holds the value of the solution at time @var{te}. @var{ie} |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
78 ## contains an index indicating which Event function was triggered in the case |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
79 ## of multiple Event functions. |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
80 ## |
20719
d903cccb8de8
doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents:
20634
diff
changeset
|
81 ## Example: Solve the @nospell{Van der Pol} equation |
20548
25623ef2ff4f
doc: Rewrite docstrings for ode* family of functions.
Rik <rik@octave.org>
parents:
20543
diff
changeset
|
82 ## |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
83 ## @example |
20548
25623ef2ff4f
doc: Rewrite docstrings for ode* family of functions.
Rik <rik@octave.org>
parents:
20543
diff
changeset
|
84 ## @group |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
85 ## fvdp = @@(@var{t},@var{y}) [@var{y}(2); (1 - @var{y}(1)^2) * @var{y}(2) - @var{y}(1)]; |
21443
acd6e203031d
Alter BIST tests stop emitting warnings during runtests invocation.
Rik <rik@octave.org>
parents:
20908
diff
changeset
|
86 ## [@var{t},@var{y}] = ode45 (fvdp, [0, 20], [2, 0]); |
20548
25623ef2ff4f
doc: Rewrite docstrings for ode* family of functions.
Rik <rik@octave.org>
parents:
20543
diff
changeset
|
87 ## @end group |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
88 ## @end example |
25026
f886561f9696
doc: improve differential eqtn docs and mention ode15i/ode15s (bug #51965).
Colin Macdonald <cbm@m.fsf.org>
parents:
24534
diff
changeset
|
89 ## @seealso{odeset, odeget, ode23, ode15s} |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
90 ## @end deftypefn |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
91 |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
92 function varargout = ode45 (fcn, trange, init, varargin) |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
93 |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
94 if (nargin < 3) |
20553
45151de7423f
maint: Clean up implementations of ode45.m, odeget.m, odeset.m.
Rik <rik@octave.org>
parents:
20549
diff
changeset
|
95 print_usage (); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
96 endif |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
97 |
28045
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
98 solver = "ode45"; |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
99 order = 5; # runge_kutta_45_dorpri uses local extrapolation |
20631
00caf63edcdf
maint: Remove obsolete ODE options from odeset/odeget/ode45.
Rik <rik@octave.org>
parents:
20620
diff
changeset
|
100 |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
101 if (nargin >= 4) |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
102 if (! isstruct (varargin{1})) |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
103 ## varargin{1:len} are parameters for fcn |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
104 odeopts = odeset (); |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
105 funarguments = varargin; |
22626 | 106 elseif (numel (varargin) > 1) |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
107 ## varargin{1} is an ODE options structure opt |
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
108 odeopts = varargin{1}; |
22626 | 109 funarguments = {varargin{2:numel (varargin)}}; |
28045
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
110 else |
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
111 ## varargin{1} is an ODE options structure opt |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
112 odeopts = varargin{1}; |
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
113 funarguments = {}; |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
114 endif |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
115 else # nargin == 3 |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
116 odeopts = odeset (); |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
117 funarguments = {}; |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
118 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
119 |
21443
acd6e203031d
Alter BIST tests stop emitting warnings during runtests invocation.
Rik <rik@octave.org>
parents:
20908
diff
changeset
|
120 if (! isnumeric (trange) || ! isvector (trange)) |
20631
00caf63edcdf
maint: Remove obsolete ODE options from odeset/odeget/ode45.
Rik <rik@octave.org>
parents:
20620
diff
changeset
|
121 error ("Octave:invalid-input-arg", |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
122 "ode45: TRANGE must be a numeric vector"); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
123 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
124 |
22626 | 125 if (numel (trange) < 2) |
20631
00caf63edcdf
maint: Remove obsolete ODE options from odeset/odeget/ode45.
Rik <rik@octave.org>
parents:
20620
diff
changeset
|
126 error ("Octave:invalid-input-arg", |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
127 "ode45: TRANGE must contain at least 2 elements"); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
128 elseif (trange(1) == trange(2)) |
20631
00caf63edcdf
maint: Remove obsolete ODE options from odeset/odeget/ode45.
Rik <rik@octave.org>
parents:
20620
diff
changeset
|
129 error ("Octave:invalid-input-arg", |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
130 "ode45: invalid time span, TRANGE(1) == TRANGE(2)"); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
131 else |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
132 direction = sign (trange(2) - trange(1)); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
133 endif |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
134 trange = trange(:); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
135 |
21443
acd6e203031d
Alter BIST tests stop emitting warnings during runtests invocation.
Rik <rik@octave.org>
parents:
20908
diff
changeset
|
136 if (! isnumeric (init) || ! isvector (init)) |
20631
00caf63edcdf
maint: Remove obsolete ODE options from odeset/odeget/ode45.
Rik <rik@octave.org>
parents:
20620
diff
changeset
|
137 error ("Octave:invalid-input-arg", |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
138 "ode45: INIT must be a numeric vector"); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
139 endif |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
140 init = init(:); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
141 |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
142 if (ischar (fcn)) |
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
143 if (! exist (fcn)) |
28041
5e44268dca6f
Replace input validation relying on str2func with alternatives (bug #57351).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
144 error ("Octave:invalid-input-arg", |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
145 ['ode45: function "' fcn '" not found']); |
28041
5e44268dca6f
Replace input validation relying on str2func with alternatives (bug #57351).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
146 endif |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
147 fcn = str2func (fcn); |
20613
27c091f4b66d
allow first argument in ode45 to be a string
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20612
diff
changeset
|
148 endif |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
149 if (! is_function_handle (fcn)) |
20631
00caf63edcdf
maint: Remove obsolete ODE options from odeset/odeget/ode45.
Rik <rik@octave.org>
parents:
20620
diff
changeset
|
150 error ("Octave:invalid-input-arg", |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
151 "ode45: FCN must be a valid function handle"); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
152 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
153 |
31417
7286327ec4b6
Improve "Events" location in ode45, ode23, ode23s (bug #63162)
Ken Marek <marek_ka@mercer.edu>
parents:
31414
diff
changeset
|
154 ## FIXME: Warn user if ! isempty (funarguments) |
7286327ec4b6
Improve "Events" location in ode45, ode23, ode23s (bug #63162)
Ken Marek <marek_ka@mercer.edu>
parents:
31414
diff
changeset
|
155 ## Not a documented behavior and may be deprecated |
7286327ec4b6
Improve "Events" location in ode45, ode23, ode23s (bug #63162)
Ken Marek <marek_ka@mercer.edu>
parents:
31414
diff
changeset
|
156 |
7286327ec4b6
Improve "Events" location in ode45, ode23, ode23s (bug #63162)
Ken Marek <marek_ka@mercer.edu>
parents:
31414
diff
changeset
|
157 |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
158 ## Start preprocessing, have a look which options are set in odeopts, |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
159 ## check if an invalid or unused option is set |
22626 | 160 [defaults, classes, attributes] = odedefaults (numel (init), |
161 trange(1), trange(end)); | |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
162 |
22660
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
163 defaults = odeset (defaults, "Refine", 4); |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
164 |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
165 persistent ode45_ignore_options = ... |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
166 {"BDF", "InitialSlope", "Jacobian", "JPattern", |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
167 "MassSingular", "MaxOrder", "MvPattern", "Vectorized"}; |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
168 |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
169 defaults = rmfield (defaults, ode45_ignore_options); |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
170 classes = rmfield (classes, ode45_ignore_options); |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
171 attributes = rmfield (attributes, ode45_ignore_options); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
172 |
22626 | 173 odeopts = odemergeopts ("ode45", odeopts, defaults, classes, attributes); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
174 |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
175 odeopts.funarguments = funarguments; |
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
176 odeopts.direction = direction; |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
177 |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
178 if (! isempty (odeopts.NonNegative)) |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
179 if (isempty (odeopts.Mass)) |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
180 odeopts.havenonnegative = true; |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
181 else |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
182 odeopts.havenonnegative = false; |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
183 warning ("Octave:invalid-input-arg", |
22626 | 184 ['ode45: option "NonNegative" is ignored', ... |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
185 " when mass matrix is set\n"]); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
186 endif |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
187 else |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
188 odeopts.havenonnegative = false; |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
189 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
190 |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
191 if (isempty (odeopts.OutputFcn) && nargout == 0) |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
192 odeopts.OutputFcn = @odeplot; |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
193 odeopts.haveoutputfunction = true; |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
194 else |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
195 odeopts.haveoutputfunction = ! isempty (odeopts.OutputFcn); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
196 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
197 |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
198 if (isempty (odeopts.InitialStep)) |
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
199 odeopts.InitialStep = odeopts.direction * ... |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
200 starting_stepsize (order, fcn, trange(1), init, |
22626 | 201 odeopts.AbsTol, odeopts.RelTol, |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
202 strcmpi (odeopts.NormControl, |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
203 "on"), odeopts.funarguments); |
22625
081a201b77c7
Clean up ode options implementation to follow Octave coding standards.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22605
diff
changeset
|
204 endif |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
205 |
28045
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
206 if (! isempty (odeopts.Mass)) |
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
207 if (isnumeric (odeopts.Mass)) |
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
208 havemasshandle = false; |
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
209 mass = odeopts.Mass; # constant mass |
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
210 elseif (is_function_handle (odeopts.Mass)) |
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
211 havemasshandle = true; # mass defined by a function handle |
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
212 else |
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
213 error ("Octave:invalid-input-arg", |
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
214 'ode45: "Mass" field must be a function handle or square matrix'); |
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
215 endif |
13dba3c069f8
Update input validation for odeXXX.m functions.
Rik <rik@octave.org>
parents:
28041
diff
changeset
|
216 else # no mass matrix - create a diag-matrix of ones for mass |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
217 havemasshandle = false; # mass = diag (ones (length (init), 1), 0); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
218 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
219 |
21443
acd6e203031d
Alter BIST tests stop emitting warnings during runtests invocation.
Rik <rik@octave.org>
parents:
20908
diff
changeset
|
220 ## Starting the initialization of the core solver ode45 |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
221 |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
222 if (havemasshandle) # Handle only the dynamic mass matrix, |
22626 | 223 if (! strcmp (odeopts.MStateDependence, "none")) |
224 ### constant mass matrices have already | |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
225 mass = @(t,x) odeopts.Mass (t, x, odeopts.funarguments{:}); |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
226 fcn = @(t,x) mass (t, x, odeopts.funarguments{:}) ... |
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
227 \ fcn (t, x, odeopts.funarguments{:}); |
22626 | 228 else |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
229 mass = @(t) odeopts.Mass (t, odeopts.funarguments{:}); |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
230 fcn = @(t,x) mass (t, odeopts.funarguments{:}) ... |
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
231 \ fcn (t, x, odeopts.funarguments{:}); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
232 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
233 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
234 |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
235 if (numel (trange) > 2) |
22659
04fc7e9c5f96
Disable Refine option of ode solvers for certain input/output combinations (partial fix bug #49408).
Rik <rik@octave.org>
parents:
22658
diff
changeset
|
236 odeopts.Refine = []; # disable Refine when specific times requested |
22658
56d7d423aff9
Return intermediate integration times when single output argument used in ode solver (bug #49417).
Rik <rik@octave.org>
parents:
22655
diff
changeset
|
237 endif |
56d7d423aff9
Return intermediate integration times when single output argument used in ode solver (bug #49417).
Rik <rik@octave.org>
parents:
22655
diff
changeset
|
238 |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
239 solution = integrate_adaptive (@runge_kutta_45_dorpri, |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
240 order, fcn, trange, init, odeopts); |
22625
081a201b77c7
Clean up ode options implementation to follow Octave coding standards.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22605
diff
changeset
|
241 |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
242 ## Postprocessing, do whatever when terminating integration algorithm |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
243 if (odeopts.haveoutputfunction) # Cleanup plotter |
22639
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
244 feval (odeopts.OutputFcn, [], [], "done", odeopts.funarguments{:}); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
245 endif |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
246 if (! isempty (odeopts.Events)) # Cleanup event function handling |
31417
7286327ec4b6
Improve "Events" location in ode45, ode23, ode23s (bug #63162)
Ken Marek <marek_ka@mercer.edu>
parents:
31414
diff
changeset
|
247 ode_event_handler ([], [], [], [], [], "done"); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
248 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
249 |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
250 ## Print additional information if option Stats is set |
22935
c9344df03da5
Allow case-insensitive option argument 'on' to ode solvers (bug #49918).
Rik <rik@octave.org>
parents:
22934
diff
changeset
|
251 if (strcmpi (odeopts.Stats, "on")) |
21955
0f3e875d9078
Fix statistics on solution solving for ode45, ode23 (bug #48243).
jcorno <jacopo.corno@gmail.com>
parents:
21634
diff
changeset
|
252 nsteps = solution.cntloop; # cntloop from 2..end |
0f3e875d9078
Fix statistics on solution solving for ode45, ode23 (bug #48243).
jcorno <jacopo.corno@gmail.com>
parents:
21634
diff
changeset
|
253 nfailed = solution.cntcycles - nsteps; # cntcycl from 1..end |
0f3e875d9078
Fix statistics on solution solving for ode45, ode23 (bug #48243).
jcorno <jacopo.corno@gmail.com>
parents:
21634
diff
changeset
|
254 nfevals = 6 * solution.cntcycles + 1; # number of ode evaluations |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
255 ndecomps = 0; # number of LU decompositions |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
256 npds = 0; # number of partial derivatives |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
257 nlinsols = 0; # no. of linear systems solutions |
22934
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
258 |
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
259 printf ("Number of successful steps: %d\n", nsteps); |
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
260 printf ("Number of failed attempts: %d\n", nfailed); |
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
261 printf ("Number of function calls: %d\n", nfevals); |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
262 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
263 |
20553
45151de7423f
maint: Clean up implementations of ode45.m, odeget.m, odeset.m.
Rik <rik@octave.org>
parents:
20549
diff
changeset
|
264 if (nargout == 2) |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
265 varargout{1} = solution.output_t; # Time stamps are first output argument |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
266 varargout{2} = solution.output_x; # Results are second output argument |
20553
45151de7423f
maint: Clean up implementations of ode45.m, odeget.m, odeset.m.
Rik <rik@octave.org>
parents:
20549
diff
changeset
|
267 elseif (nargout == 1) |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
268 varargout{1}.x = solution.ode_t.'; #Time stamps saved in field x (row vect.) |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
269 varargout{1}.y = solution.ode_x.'; #Results are saved in field y (row vect.) |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
270 varargout{1}.solver = solver; # Solver name is saved in field solver |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
271 if (! isempty (odeopts.Events)) |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
272 varargout{1}.xe = solution.event{3}.'; # Time info when an event occurred |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
273 varargout{1}.ye = solution.event{4}.'; # Results when an event occurred |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
274 varargout{1}.ie = solution.event{2}.'; # Index info which event occurred |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
275 endif |
22935
c9344df03da5
Allow case-insensitive option argument 'on' to ode solvers (bug #49918).
Rik <rik@octave.org>
parents:
22934
diff
changeset
|
276 if (strcmpi (odeopts.Stats, "on")) |
20553
45151de7423f
maint: Clean up implementations of ode45.m, odeget.m, odeset.m.
Rik <rik@octave.org>
parents:
20549
diff
changeset
|
277 varargout{1}.stats = struct (); |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
278 varargout{1}.stats.nsteps = nsteps; |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
279 varargout{1}.stats.nfailed = nfailed; |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
280 varargout{1}.stats.nfevals = nfevals; |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
281 varargout{1}.stats.npds = npds; |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
282 varargout{1}.stats.ndecomps = ndecomps; |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
283 varargout{1}.stats.nlinsols = nlinsols; |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
284 endif |
22937
2b2ac017c901
Fix undefined return argument for more than 2 outputs from ode solver (bug #49890).
Rik <rik@octave.org>
parents:
22660
diff
changeset
|
285 elseif (nargout > 2) |
20553
45151de7423f
maint: Clean up implementations of ode45.m, odeget.m, odeset.m.
Rik <rik@octave.org>
parents:
20549
diff
changeset
|
286 varargout = cell (1,5); |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
287 varargout{1} = solution.output_t; |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
288 varargout{2} = solution.output_x; |
22593
dba5074bdc79
simplify options management in ode solvers
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22445
diff
changeset
|
289 if (! isempty (odeopts.Events)) |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
290 varargout{3} = solution.event{3}; # Time info when an event occurred |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
291 varargout{4} = solution.event{4}; # Results when an event occurred |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
292 varargout{5} = solution.event{2}; # Index info which event occurred |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
293 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
294 endif |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
295 |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
296 endfunction |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
297 |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
298 |
21599
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
299 %!demo |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
300 %! ## Demonstrate convergence order for ode45 |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
301 %! tol = 1e-5 ./ 10.^[0:8]; |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
302 %! for i = 1 : numel (tol) |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
303 %! opt = odeset ("RelTol", tol(i), "AbsTol", realmin); |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
304 %! [t, y] = ode45 (@(t, y) -y, [0, 1], 1, opt); |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
305 %! h(i) = 1 / (numel (t) - 1); |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
306 %! err(i) = norm (y .* exp (t) - 1, Inf); |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
307 %! endfor |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
308 %! |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
309 %! ## Estimate order visually |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
310 %! loglog (h, tol, "-ob", |
22445
cbac595d23ac
Fix %!demo blocks for ode23 and ode45
Mike Miller <mtmiller@octave.org>
parents:
22323
diff
changeset
|
311 %! h, err, "-b", |
21599
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
312 %! h, (h/h(end)) .^ 4 .* tol(end), "k--", |
22626 | 313 %! h, (h/h(end)) .^ 5 .* tol(end), "k-"); |
21599
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
314 %! axis tight |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
315 %! xlabel ("h"); |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
316 %! ylabel ("err(h)"); |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
317 %! title ("Convergence plot for ode45"); |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
318 %! legend ("imposed tolerance", "ode45 (relative) error", |
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
319 %! "order 4", "order 5", "location", "northwest"); |
22647
cf8ec7abb4ae
Clean up demo and test blocks for ode functions.
Rik <rik@octave.org>
parents:
22644
diff
changeset
|
320 %! |
cf8ec7abb4ae
Clean up demo and test blocks for ode functions.
Rik <rik@octave.org>
parents:
22644
diff
changeset
|
321 %! ## Estimate order numerically |
cf8ec7abb4ae
Clean up demo and test blocks for ode functions.
Rik <rik@octave.org>
parents:
22644
diff
changeset
|
322 %! p = diff (log (err)) ./ diff (log (h)) |
21599
f29d68e24c5a
ode23.m, ode45.m: More reformatting of demos to Octave coding standards.
Rik <rik@octave.org>
parents:
21596
diff
changeset
|
323 |
22934
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
324 ## We are using the Van der Pol equation for all tests. |
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
325 ## Further tests also define a reference solution (computed at high accuracy) |
28563
5a07c798eb08
avoid function call input or output argument number mismatch
John W. Eaton <jwe@octave.org>
parents:
28045
diff
changeset
|
326 %!function ydot = fpol (t, y, varargin) # The Van der Pol ODE |
22626 | 327 %! ydot = [y(2); (1 - y(1)^2) * y(2) - y(1)]; |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
328 %!endfunction |
21443
acd6e203031d
Alter BIST tests stop emitting warnings during runtests invocation.
Rik <rik@octave.org>
parents:
20908
diff
changeset
|
329 %!function ref = fref () # The computed reference solution |
22626 | 330 %! ref = [0.32331666704577, -1.83297456798624]; |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
331 %!endfunction |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
332 %!function [val, trm, dir] = feve (t, y, varargin) |
28563
5a07c798eb08
avoid function call input or output argument number mismatch
John W. Eaton <jwe@octave.org>
parents:
28045
diff
changeset
|
333 %! val = fpol (t, y, varargin{:}); # We use the derivatives |
22934
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
334 %! trm = zeros (2,1); # that's why component 2 |
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
335 %! dir = ones (2,1); # does not seem to be exact |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
336 %!endfunction |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
337 %!function [val, trm, dir] = fevn (t, y, varargin) |
28563
5a07c798eb08
avoid function call input or output argument number mismatch
John W. Eaton <jwe@octave.org>
parents:
28045
diff
changeset
|
338 %! val = fpol (t, y, varargin{:}); # We use the derivatives |
22934
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
339 %! trm = ones (2,1); # that's why component 2 |
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
340 %! dir = ones (2,1); # does not seem to be exact |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
341 %!endfunction |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
342 %!function mas = fmas (t, y, varargin) |
22934
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
343 %! mas = [1, 0; 0, 1]; # Dummy mass matrix for tests |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
344 %!endfunction |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
345 %!function mas = fmsa (t, y, varargin) |
22934
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
346 %! mas = sparse ([1, 0; 0, 1]); # A sparse dummy matrix |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
347 %!endfunction |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
348 %!function out = fout (t, y, flag, varargin) |
22639
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
349 %! out = false; |
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
350 %! if (strcmp (flag, "init")) |
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
351 %! if (! isequal (size (t), [2, 1])) |
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
352 %! error ('fout: step "init"'); |
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
353 %! endif |
22626 | 354 %! elseif (isempty (flag)) |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
355 %! # Multiple steps can be sent in one function call |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
356 %! if (! isequal ( size (t), size (y))) |
22639
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
357 %! error ('fout: step "calc"'); |
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
358 %! endif |
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
359 %! elseif (strcmp (flag, "done")) |
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
360 %! if (! isempty (t)) |
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
361 %! warning ('fout: step "done"'); |
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
362 %! endif |
22626 | 363 %! else |
22639
7efa2d0e22c9
More Matlab-compatible implementation of OutputFcn. Clean up odeplot.m.
Rik <rik@octave.org>
parents:
22626
diff
changeset
|
364 %! error ("fout: invalid flag <%s>", flag); |
22626 | 365 %! endif |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
366 %!endfunction |
31495
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
367 %!function stop_solve = OutputSel_test (t, y, flag, x) |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
368 %! ## x == 1: select y(1) |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
369 %! ## x == 2: select y(2) |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
370 %! ## x == 3: select y([1,2]) |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
371 %! persistent y_last |
31499
e7b51b5b33f8
maint: Use more Octave coding conventions in cset c05ef94a2bbc.
Rik <rik@octave.org>
parents:
31495
diff
changeset
|
372 %! if (strcmp (flag, "init")) |
31495
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
373 %! y_last = y; |
31499
e7b51b5b33f8
maint: Use more Octave coding conventions in cset c05ef94a2bbc.
Rik <rik@octave.org>
parents:
31495
diff
changeset
|
374 %! if (x == 1 || x == 2) |
31495
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
375 %! assert (length (y) == 1); |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
376 %! elseif (x == 3) |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
377 %! assert (length (y) == 2); |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
378 %! endif |
31499
e7b51b5b33f8
maint: Use more Octave coding conventions in cset c05ef94a2bbc.
Rik <rik@octave.org>
parents:
31495
diff
changeset
|
379 %! elseif (strcmp (flag, "done")) |
31495
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
380 %! y_exp = fref ().'; |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
381 %! if (x < 3) |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
382 %! assert (y_last, y_exp(x), 1e-4); |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
383 %! else |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
384 %! assert (y_last, y_exp, 1e-4); |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
385 %! endif |
31499
e7b51b5b33f8
maint: Use more Octave coding conventions in cset c05ef94a2bbc.
Rik <rik@octave.org>
parents:
31495
diff
changeset
|
386 %! else # flag == "" |
31495
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
387 %! y_last = y(:,end); |
31499
e7b51b5b33f8
maint: Use more Octave coding conventions in cset c05ef94a2bbc.
Rik <rik@octave.org>
parents:
31495
diff
changeset
|
388 %! if (x == 1 || x == 2) |
31495
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
389 %! assert (length (t) == length (y)); |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
390 %! else |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
391 %! assert (2 * length (t) == length (y(:))); |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
392 %! endif |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
393 %! endif |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
394 %! stop_solve = 0; |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
395 %!endfunction |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
diff
changeset
|
396 %! |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
397 %!test # two output arguments |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
398 %! [t, y] = ode45 (@fpol, [0 2], [2 0]); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
399 %! assert ([t(end), y(end,:)], [2, fref], 1e-2); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
400 %!test # not too many steps |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
401 %! [t, y] = ode45 (@fpol, [0 2], [2 0], odeset("Refine",1)); |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
402 %! assert (size (t) < 20); |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
403 %!test # correct number of steps with Refine |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
404 %! [t1, y1] = ode45 (@fpol, [0 2], [2 0], odeset ("Refine", 1)); |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
405 %! [t2, y2] = ode45 (@fpol, [0 2], [2 0], odeset ("Refine", 4)); |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
406 %! [t3, y3] = ode45 (@fpol, [0 2], [2 0]); #default Refine=4 |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
407 %! s = ode45 (@fpol, [0 2], [2 0], odeset ("Refine", 4)); |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
408 %! assert (length (t2) == length (t3)); |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
409 %! assert (length (t2) == 4*length (t1) - 3); |
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
410 %! assert (length (s.x) == length (t1)); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
411 %!test # anonymous function instead of real function |
22644
23941beb44cd
Cleanup variable names, obsolete ChangeLog info in ode23, ode45.
Rik <rik@octave.org>
parents:
22643
diff
changeset
|
412 %! fvdp = @(t,y) [y(2); (1 - y(1)^2) * y(2) - y(1)]; |
23941beb44cd
Cleanup variable names, obsolete ChangeLog info in ode23, ode45.
Rik <rik@octave.org>
parents:
22643
diff
changeset
|
413 %! [t, y] = ode45 (fvdp, [0 2], [2 0]); |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
414 %! assert ([t(end), y(end,:)], [2, fref], 1e-2); |
20613
27c091f4b66d
allow first argument in ode45 to be a string
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20612
diff
changeset
|
415 %!test # string instead of function |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
416 %! [t, y] = ode45 ("fpol", [0 2], [2 0]); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
417 %! assert ([t(end), y(end,:)], [2, fref], 1e-2); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
418 %!test # extra input arguments passed through |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
419 %! [t, y] = ode45 (@fpol, [0 2], [2 0], 12, 13, "KL"); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
420 %! assert ([t(end), y(end,:)], [2, fref], 1e-2); |
20631
00caf63edcdf
maint: Remove obsolete ODE options from odeset/odeget/ode45.
Rik <rik@octave.org>
parents:
20620
diff
changeset
|
421 %!test # empty ODEOPT structure *but* extra input arguments |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
422 %! opt = odeset; |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
423 %! [t, y] = ode45 (@fpol, [0 2], [2 0], opt, 12, 13, "KL"); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
424 %! assert ([t(end), y(end,:)], [2, fref], 1e-2); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
425 %!test # Solve another anonymous function below zero |
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
426 %! vref = [0, 14.77810590694212]; |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
427 %! [t, y] = ode45 (@(t,y) y, [-2 0], 2); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
428 %! assert ([t(end), y(end,:)], vref, 1e-1); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
429 %!test # InitialStep option |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
430 %! opt = odeset ("InitialStep", 1e-8, "Refine", 1); |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
431 %! [t, y] = ode45 (@fpol, [0 0.2], [2 0], opt); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
432 %! assert ([t(2)-t(1)], [1e-8], 1e-9); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
433 %!test # MaxStep option |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
434 %! opt = odeset ("MaxStep", 1e-3); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
435 %! sol = ode45 (@fpol, [0 0.2], [2 0], opt); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
436 %! assert ([sol.x(5)-sol.x(4)], [1e-3], 1e-3); |
22659
04fc7e9c5f96
Disable Refine option of ode solvers for certain input/output combinations (partial fix bug #49408).
Rik <rik@octave.org>
parents:
22658
diff
changeset
|
437 %!test # Solve with intermediate step |
04fc7e9c5f96
Disable Refine option of ode solvers for certain input/output combinations (partial fix bug #49408).
Rik <rik@octave.org>
parents:
22658
diff
changeset
|
438 %! [t, y] = ode45 (@fpol, [0 1 2], [2 0]); |
28912
0de38a6ef693
maint: Use Octave convention of space after function name in scripts dir.
Rik <rik@octave.org>
parents:
28896
diff
changeset
|
439 %! assert (any ((t-1) == 0)); |
22659
04fc7e9c5f96
Disable Refine option of ode solvers for certain input/output combinations (partial fix bug #49408).
Rik <rik@octave.org>
parents:
22658
diff
changeset
|
440 %! assert ([t(end), y(end,:)], [2, fref], 1e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
441 %!test # Solve in backward direction starting at t=0 |
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
442 %! vref = [-1.205364552835178, 0.951542399860817]; |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
443 %! sol = ode45 (@fpol, [0 -2], [2 0]); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
444 %! assert ([sol.x(end); sol.y(:,end)], [-2; vref'], 1e-2); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
445 %!test # Solve in backward direction starting at t=2 |
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
446 %! vref = [-1.205364552835178, 0.951542399860817]; |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
447 %! sol = ode45 (@fpol, [2 -2], fref); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
448 %! assert ([sol.x(end); sol.y(:,end)], [-2; vref'], 1e-2); |
22659
04fc7e9c5f96
Disable Refine option of ode solvers for certain input/output combinations (partial fix bug #49408).
Rik <rik@octave.org>
parents:
22658
diff
changeset
|
449 %!test # Solve in backward direction starting at t=2, with intermediate step |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
450 %! vref = [-1.205364552835178, 0.951542399860817]; |
22659
04fc7e9c5f96
Disable Refine option of ode solvers for certain input/output combinations (partial fix bug #49408).
Rik <rik@octave.org>
parents:
22658
diff
changeset
|
451 %! [t, y] = ode45 (@fpol, [2 0 -2], fref); |
28912
0de38a6ef693
maint: Use Octave convention of space after function name in scripts dir.
Rik <rik@octave.org>
parents:
28896
diff
changeset
|
452 %! idx = find (y < 0, 1, "first") - 1; |
22659
04fc7e9c5f96
Disable Refine option of ode solvers for certain input/output combinations (partial fix bug #49408).
Rik <rik@octave.org>
parents:
22658
diff
changeset
|
453 %! assert ([t(idx), y(idx,:)], [0,2,0], 1e-2); |
04fc7e9c5f96
Disable Refine option of ode solvers for certain input/output combinations (partial fix bug #49408).
Rik <rik@octave.org>
parents:
22658
diff
changeset
|
454 %! assert ([t(end), y(end,:)], [-2, vref], 1e-2); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
455 %!test # Solve another anonymous function in backward direction |
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
456 %! vref = [-1, 0.367879437558975]; |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
457 %! sol = ode45 (@(t,y) y, [0 -1], 1); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
458 %! assert ([sol.x(end); sol.y(:,end)], vref', 1e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
459 %!test # Solve another anonymous function below zero |
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
460 %! vref = [0, 14.77810590694212]; |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
461 %! sol = ode45 (@(t,y) y, [-2 0], 2); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
462 %! assert ([sol.x(end); sol.y(:,end)], vref', 1e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
463 %!test # Solve in backward direction starting at t=0 with MaxStep option |
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
464 %! vref = [-1.205364552835178, 0.951542399860817]; |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
465 %! opt = odeset ("MaxStep", 1e-3); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
466 %! sol = ode45 (@fpol, [0 -2], [2 0], opt); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
467 %! assert ([abs(sol.x(8)-sol.x(7))], [1e-3], 1e-3); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
468 %! assert ([sol.x(end); sol.y(:,end)], [-2; vref'], 1e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
469 %!test # AbsTol option |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
470 %! opt = odeset ("AbsTol", 1e-5); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
471 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
472 %! assert ([sol.x(end); sol.y(:,end)], [2; fref'], 1e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
473 %!test # AbsTol and RelTol option |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
474 %! opt = odeset ("AbsTol", 1e-8, "RelTol", 1e-8); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
475 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
476 %! assert ([sol.x(end); sol.y(:,end)], [2; fref'], 1e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
477 %!test # RelTol and NormControl option -- higher accuracy |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
478 %! opt = odeset ("RelTol", 1e-8, "NormControl", "on"); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
479 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
480 %! assert ([sol.x(end); sol.y(:,end)], [2; fref'], 1e-5); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
481 %!test # Keeps initial values while integrating |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
482 %! opt = odeset ("NonNegative", 2); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
483 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
484 %! assert ([sol.x(end); sol.y(:,end)], [2; 2; 0], 0.5); |
31495
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
485 %!test # OutputSel 1 (see function OutputSel_test for asserts) |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
486 %! opt = odeset ("OutputFcn", @(t, y, flag) OutputSel_test (t, y, flag, 1), ... |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
487 %! "OutputSel", 1); |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
488 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
489 %!test # OutputSel 2 (see function OutputSel_test for asserts) |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
490 %! opt = odeset ("OutputFcn", @(t, y, flag) OutputSel_test (t, y, flag, 2), ... |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
491 %! "OutputSel", 2); |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
492 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
493 %!test # OutputSel [1,2] (see function OutputSel_test for asserts) |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
494 %! opt = odeset ("OutputFcn", @(t, y, flag) OutputSel_test (t, y, flag, 3), ... |
4cb81dcc5cc5
Add BIST for OutputSel option in ode23, ode23s, ode45 (bug #63229)
Ken Marek <marek_ka@mercer.edu>
parents:
31417
diff
changeset
|
495 %! "OutputSel", [1,2]); |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
496 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
497 %!test # Stats must add further elements in sol |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
498 %! opt = odeset ("Stats", "on"); |
22934
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
499 %! stat_str = evalc ("sol = ode45 (@fpol, [0 2], [2 0], opt);"); |
bb452f84a299
Fix printing of solution stats in ode23/ode45 solvers (bug #49918).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22755
diff
changeset
|
500 %! assert (strncmp (stat_str, "Number of successful steps:", 27)); |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
501 %! assert (isfield (sol, "stats")); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
502 %! assert (isfield (sol.stats, "nsteps")); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
503 %!test # Events option add further elements in sol |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
504 %! opt = odeset ("Events", @feve); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
505 %! sol = ode45 (@fpol, [0 10], [2 0], opt); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
506 %! assert (isfield (sol, "ie")); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
507 %! assert (sol.ie(1), 2); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
508 %! assert (isfield (sol, "xe")); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
509 %! assert (isfield (sol, "ye")); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
510 %!test # Events option, now stop integration |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
511 %! opt = odeset ("Events", @fevn, "NormControl", "on"); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
512 %! sol = ode45 (@fpol, [0 10], [2 0], opt); |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
513 %! assert ([sol.ie, sol.xe, sol.ye.'], |
31417
7286327ec4b6
Improve "Events" location in ode45, ode23, ode23s (bug #63162)
Ken Marek <marek_ka@mercer.edu>
parents:
31414
diff
changeset
|
514 %! [2.0, 2.496110, -0.830550, -2.677589], 2e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
515 %!test # Events option, five output arguments |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
516 %! opt = odeset ("Events", @fevn, "NormControl", "on"); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
517 %! [t, y, vxe, ye, vie] = ode45 (@fpol, [0 10], [2 0], opt); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
518 %! assert ([vie, vxe, ye], |
31417
7286327ec4b6
Improve "Events" location in ode45, ode23, ode23s (bug #63162)
Ken Marek <marek_ka@mercer.edu>
parents:
31414
diff
changeset
|
519 %! [2.0, 2.496110, -0.830550, -2.677589], 2e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
520 %!test # Mass option as function |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
521 %! opt = odeset ("Mass", @fmas); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
522 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
523 %! assert ([sol.x(end); sol.y(:,end)], [2; fref'], 1e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
524 %!test # Mass option as matrix |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
525 %! opt = odeset ("Mass", eye (2,2)); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
526 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
527 %! assert ([sol.x(end); sol.y(:,end)], [2; fref'], 1e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
528 %!test # Mass option as sparse matrix |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
529 %! opt = odeset ("Mass", sparse (eye (2,2))); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
530 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
531 %! assert ([sol.x(end); sol.y(:,end)], [2; fref'], 1e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
532 %!test # Mass option as function and sparse matrix |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
533 %! opt = odeset ("Mass", @fmsa); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
534 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
535 %! assert ([sol.x(end); sol.y(:,end)], [2; fref'], 1e-3); |
20549
e368ce72a844
maint: Use Octave coding conventions for ode* functions.
Rik <rik@octave.org>
parents:
20548
diff
changeset
|
536 %!test # Mass option as function and MStateDependence |
20634
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
537 %! opt = odeset ("Mass", @fmas, "MStateDependence", "strong"); |
80e630b37ba1
maint: Remove unnecessary 'v' prefix before variables in ODE m-files.
Rik <rik@octave.org>
parents:
20631
diff
changeset
|
538 %! sol = ode45 (@fpol, [0 2], [2 0], opt); |
22654
bc61ed076549
Change orientation of output fields in struct returned from ode solvers (bug #49402).
Sebastian Schöps <sebastian@schoeps.org>
parents:
22647
diff
changeset
|
539 %! assert ([sol.x(end); sol.y(:,end)], [2; fref'], 1e-3); |
21443
acd6e203031d
Alter BIST tests stop emitting warnings during runtests invocation.
Rik <rik@octave.org>
parents:
20908
diff
changeset
|
540 |
22660
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
541 ## Note: The following options have no effect on this solver |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
542 ## therefore it makes no sense to test them here: |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
543 ## |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
544 ## "BDF" |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
545 ## "InitialSlope" |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
546 ## "JPattern" |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
547 ## "Jacobian" |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
548 ## "MassSingular" |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
549 ## "MaxOrder" |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
550 ## "MvPattern" |
7eb3f8ec1aed
Remove FIXME comment about missing tests for ignored ODE options.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22659
diff
changeset
|
551 ## "Vectorized" |
22626 | 552 |
31499
e7b51b5b33f8
maint: Use more Octave coding conventions in cset c05ef94a2bbc.
Rik <rik@octave.org>
parents:
31495
diff
changeset
|
553 %!test # Check that imaginary part of solution does not get inverted |
22655
6b134d294d61
ode solvers: use ordinary transpose instead of Hermitian conjugate (bug #49410).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22654
diff
changeset
|
554 %! sol = ode45 (@(x,y) 1, [0 1], 1i); |
28929
9e43deb9bfc3
maint: Use semicolon after assert statement inside %!test blocks.
Rik <rik@octave.org>
parents:
28912
diff
changeset
|
555 %! assert (imag (sol.y), ones (size (sol.y))); |
31263
449ed6f427cb
ode45/23/23s: Implement Events, OutputFcn, & Refine options (bug #49408 and #63063)
Ken Marek <marek_ka@mercer.edu>
parents:
30893
diff
changeset
|
556 %! [x, y] = ode45 (@(x,y) 1, [0 1], 1i, odeset ("Refine", 1)); |
28929
9e43deb9bfc3
maint: Use semicolon after assert statement inside %!test blocks.
Rik <rik@octave.org>
parents:
28912
diff
changeset
|
557 %! assert (imag (y), ones (size (y))); |
22655
6b134d294d61
ode solvers: use ordinary transpose instead of Hermitian conjugate (bug #49410).
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22654
diff
changeset
|
558 |
28896
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
28892
diff
changeset
|
559 %!error <Invalid call> ode45 () |
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
28892
diff
changeset
|
560 %!error <Invalid call> ode45 (1) |
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
28892
diff
changeset
|
561 %!error <Invalid call> ode45 (1,2) |
22626 | 562 %!error <TRANGE must be a numeric> ode45 (@fpol, {[0 25]}, [3 15 1]) |
563 %!error <TRANGE must be a .* vector> ode45 (@fpol, [0 25; 25 0], [3 15 1]) | |
564 %!error <TRANGE must contain at least 2 elements> ode45 (@fpol, [1], [3 15 1]) | |
565 %!error <invalid time span> ode45 (@fpol, [1 1], [3 15 1]) | |
566 %!error <INIT must be a numeric> ode45 (@fpol, [0 25], {[3 15 1]}) | |
567 %!error <INIT must be a .* vector> ode45 (@fpol, [0 25], [3 15 1; 3 15 1]) | |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
568 %!error <FCN must be a valid function handle> ode45 (1, [0 25], [3 15 1]) |