Mercurial > octave
annotate scripts/ode/private/runge_kutta_23.m @ 21546:f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
* isrecording.m, soundsc.m, delaunay3.m, cell2mat.m, cumtrapz.m, del2.m,
inputParser.m, interp1.m, interp3.m, narginchk.m, profile.m,
validateattributes.m, delaunayn.m, tsearchn.m, voronoin.m, brighten.m,
cmunique.m, colorcube.m, imfinfo.m, imshow.m, edit.m, orderfields.m, run.m,
warning_ids.m, ode23.m, ode45.m, odeget.m, integrate_adaptive.m, kahan.m,
ode_struct_value_check.m, runge_kutta_23.m, fminunc.m, fsolve.m, fzero.m,
pkg.m, build.m, specular.m, view.m, bar.m, barh.m, contour3.m, isosurface.m,
line.m, pie.m, pie3.m, quiver3.m, scatter.m, scatter3.m, stem3.m, stemleaf.m,
surfl.m, tetramesh.m, isfigure.m, mkpp.m, pchip.m, residue.m, splinefit.m,
rmpref.m, unique.m, eigs.m, ilu.m, factor.m, factorial.m, gallery.m, hankel.m,
histc.m, ols.m, finv.m, fpdf.m, kruskal_wallis_test.m, weekday.m:
Wrap m-file docstrings to 79 characters + newline (80 total).
author | Rik <rik@octave.org> |
---|---|
date | Sun, 27 Mar 2016 15:50:01 -0700 |
parents | 8880d93010d8 |
children | 74257c267c8b |
rev | line source |
---|---|
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
1 ## Copyright (C) 2013-2015, Jacopo Corno <jacopo.corno@gmail.com> |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
2 ## Copyright (C) 2013-2015, Roberto Porcu' <roberto.porcu@polimi.it> |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
3 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
4 ## This file is part of Octave. |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
5 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
6 ## Octave is free software; you can redistribute it and/or modify it |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
7 ## under the terms of the GNU General Public License as published by |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
9 ## your option) any later version. |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
10 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
11 ## Octave is distributed in the hope that it will be useful, but |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
14 ## General Public License for more details. |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
15 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
16 ## You should have received a copy of the GNU General Public License |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
17 ## along with Octave; see the file COPYING. If not, see |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
18 ## <http://www.gnu.org/licenses/>. |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
19 |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
20 ## -*- texinfo -*- |
21319
8880d93010d8
Remove further uses of CLASS field in @deftypefn macro.
Rik <rik@octave.org>
parents:
21122
diff
changeset
|
21 ## @deftypefn {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23 (@var{@fun}, @var{t}, @var{x}, @var{dt}) |
8880d93010d8
Remove further uses of CLASS field in @deftypefn macro.
Rik <rik@octave.org>
parents:
21122
diff
changeset
|
22 ## @deftypefnx {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23 (@var{@fun}, @var{t}, @var{x}, @var{dt}, @var{options}) |
8880d93010d8
Remove further uses of CLASS field in @deftypefn macro.
Rik <rik@octave.org>
parents:
21122
diff
changeset
|
23 ## @deftypefnx {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23 (@var{@fun}, @var{t}, @var{x}, @var{dt}, @var{options}, @var{k_vals_in}) |
8880d93010d8
Remove further uses of CLASS field in @deftypefn macro.
Rik <rik@octave.org>
parents:
21122
diff
changeset
|
24 ## @deftypefnx {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23 (@var{@fun}, @var{t}, @var{x}, @var{dt}, @var{options}, @var{k_vals_in}, @var{t_next}) |
8880d93010d8
Remove further uses of CLASS field in @deftypefn macro.
Rik <rik@octave.org>
parents:
21122
diff
changeset
|
25 ## @deftypefnx {} {[@var{t_next}, @var{x_next}, @var{x_est}] =} runge_kutta_23 (@dots{}) |
8880d93010d8
Remove further uses of CLASS field in @deftypefn macro.
Rik <rik@octave.org>
parents:
21122
diff
changeset
|
26 ## @deftypefnx {} {[@var{t_next}, @var{x_next}, @var{x_est}, @var{k_vals_out}] =} runge_kutta_23 (@dots{}) |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
27 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
28 ## This function can be used to integrate a system of ODEs with a given initial |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
29 ## condition @var{x} from @var{t} to @var{t+dt}, with the Bogacki-Shampine |
21122
dba88797f69f
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
20928
diff
changeset
|
30 ## method of third order. For the definition of this method see |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
31 ## @url{http://en.wikipedia.org/wiki/List_of_Runge%E2%80%93Kutta_methods}. |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
32 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
33 ## @var{@fun} is a function handle that defines the ODE: @code{y' = f(tau,y)}. |
21546
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
21319
diff
changeset
|
34 ## The function must accept two inputs where the first is time @var{tau} and |
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
21319
diff
changeset
|
35 ## the second is a column vector of unknowns @var{y}. |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
36 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
37 ## @var{t} is the first extreme of integration interval. |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
38 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
39 ## @var{x} is the initial condition of the system.. |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
40 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
41 ## @var{dt} is the timestep, that is the length of the integration interval. |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
42 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
43 ## The optional fourth argument @var{options} specifies options for the ODE |
21122
dba88797f69f
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
20928
diff
changeset
|
44 ## solver. It is a structure generated by @code{odeset}. In particular it |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
45 ## contains the field @var{funarguments} with the optional arguments to be used |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
46 ## in the evaluation of @var{fun}. |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
47 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
48 ## The optional fifth argument @var{k_vals_in} contains the Runge-Kutta |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
49 ## evaluations of the previous step to use in a FSAL scheme. |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
50 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
51 ## The optional sixth argument @var{t_next} (@code{t_next = t + dt}) specifies |
21122
dba88797f69f
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
20928
diff
changeset
|
52 ## the end of the integration interval. The output @var{x_next} s the higher |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
53 ## order computed solution at time @var{t_next} (local extrapolation is |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
54 ## performed). |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
55 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
56 ## Optionally the functions can also return @var{x_est}, a lower order solution |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
57 ## for the estimation of the error, and @var{k_vals_out}, a matrix containing |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
58 ## the Runge-Kutta evaluations to use in a FSAL scheme or for dense output. |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
59 ## |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
60 ## @seealso{runge_kutta_45_dorpri} |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
61 ## @end deftypefn |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
62 |
20903
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
63 function [t_next, x_next, x_est, k] = runge_kutta_23 (f, t, x, dt, |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
64 options = [], |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
65 k_vals = [], |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
66 t_next = t + dt) |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
67 |
20903
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
68 persistent a = [0 0 0; |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
69 1/2 0 0; |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
70 0 3/4 0]; |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
71 persistent b = [0 1/2 3/4 1]; |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
72 persistent c = [(2/9) (1/3) (4/9)]; |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
73 persistent c_prime = [(7/24) (1/4) (1/3) (1/8)]; |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
74 |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
75 s = t + dt * b; |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
76 cc = dt * c; |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
77 aa = dt * a; |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
78 k = zeros (rows (x), 4); |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
79 |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
80 if (! isempty (options)) # extra arguments for function evaluator |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
81 args = options.funarguments; |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
82 else |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
83 args = {}; |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
84 endif |
20928
2b8447888e0a
strip trailing whitespace from files
John W. Eaton <jwe@octave.org>
parents:
20903
diff
changeset
|
85 |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
86 if (! isempty (k_vals)) # k values from previous step are passed |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
87 k(:,1) = k_vals(:,end); # FSAL property |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
88 else |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
89 k(:,1) = feval (f, t, x, args{:}); |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
90 endif |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
91 |
20903
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
92 k(:,2) = feval (f, s(2), x + k(:,1) * aa(2, 1).', args{:}); |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
93 k(:,3) = feval (f, s(3), x + k(:,2) * aa(3, 2).', args{:}); |
20928
2b8447888e0a
strip trailing whitespace from files
John W. Eaton <jwe@octave.org>
parents:
20903
diff
changeset
|
94 |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
95 ## compute new time and new values for the unkwnowns |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
96 ## t_next = t + dt; |
20903
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
97 x_next = x + k(:,1:3) * cc(:); # 3rd order approximation |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
98 |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
99 ## if the estimation of the error is required |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
100 if (nargout >= 3) |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
101 ## new solution to be compared with the previous one |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
102 k(:,4) = feval (f, t_next, x_next, args{:}); |
20903
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
103 cc_prime = dt * c_prime; |
3d3da166dac5
2015 Code Sprint: finish import of ode23 into core
Carlo de Falco <carlo.defalco@polimi.it>
parents:
20901
diff
changeset
|
104 x_est = x + k * cc_prime(:); |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
105 endif |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
106 |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
diff
changeset
|
107 endfunction |