From: Luca Cerone on
Hi everybody,
I'm using Matlab solvers to solve an ODE system.

I'm wondering if there is a way to get as output not only
the solution of the system, but also how the derivative
defining the system change with time.
I mean I'd like to know also the values for dydt as evaluated
by the solver, is there any option to get this values?
Thanks a lot in advance,
Cheers, -luca
From: Steven Lord on

"Luca Cerone" <luca_cerone#_remove_this#@yahoo.it> wrote in message
news:hrou5e$oro$1(a)fred.mathworks.com...
> Hi everybody,
> I'm using Matlab solvers to solve an ODE system.
>
> I'm wondering if there is a way to get as output not only
> the solution of the system, but also how the derivative
> defining the system change with time.
> I mean I'd like to know also the values for dydt as evaluated
> by the solver, is there any option to get this values?

After you've solved the system, you have t and y outputs along with a
function that, given t and y, computes dydt. Make one final call to your
function to compute dydt at the times returned by the solver. Alternately,
if your function is expensive to evaluate and you need only an approximate
derivative, look at the DIFF function.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Luca Cerone on
Hi Steven,
thanks for your quick answer,
actually I tried your solution, but it doesn't
work and the reason is very simple:
odesolver pass y to the function defining the system as a column vector and as such I treat it.
I wrote a simple function that use the output t and y from ode solvers as well as the handler of the function defining the system and evaluates the derivatives.
It can be found in fileexchange as getODEderivatives with full explanation and an example.
Thanks again for your suggestion.
luca
"Steven Lord" <slord(a)mathworks.com> wrote in message <hrp7rv$56r$1(a)fred.mathworks.com>...
>
> After you've solved the system, you have t and y outputs along with a
> function that, given t and y, computes dydt. Make one final call to your
> function to compute dydt at the times returned by the solver. Alternately,
> if your function is expensive to evaluate and you need only an approximate
> derivative, look at the DIFF function.
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
 | 
Pages: 1
Prev: How to sort a 2-d matrix
Next: ode with boundaries