On 6 Oct 2015, at 09:44, Richard Crozier <address@hidden> wrote:
There is an undocumented feature of matlab's ode45 and most of the other ode*
functions. They pass any additional arguments to ode45 after the 'options'
arguments to the ode evaluation function, crossing detection function and
output function. This is really useful and would be nice to have in Octave's
versions too if it's not present.
This feature is present in the current version of ode45 in Octave, but I think
it was deprecated in Matlab.
The recommended way of achieving the same result is via a anonymous function,
i.e., supposing you have
function r = resfun (t, y, z)
r = t + y + z;
endfunction
instead of using the deprecated approach of passing the extra parameter z as an
additional input to de45:
ode45 (@resfun, tspan, y0, options, z)
you use an anonymous function to bind the value of z
ode45 (@(t, y) resfun(t, y, z), tspan, y0, options)
this techinique is reccomended in Matlab [1, 2], but the old behaviour, now
deprecated and undocumented, is still
working and I think is kept for bacward compatibility.
In the Octave implementation I was considering removing this feature as it make
the code much more complicated.
Richard
c.
[1] http://it.mathworks.com/help/matlab/ref/ode45.html "Parameterizing Functions
explains how to provide additional parameters to the function fun, if necessary."
[2] http://it.mathworks.com/help/matlab/math/parameterizing-functions.html