From: Plank on
Hey folks,

I'm having some difficulty with syntax/understanding around the ODE functions. What I'm working on at the moment is a function, BigFunction(6 parameters) that returns a 19 element answer. I then need to apply ode23tb to this answer for 10 steps - but I'm getting well hung up on the syntax for these things as well as my general lack of heavy matlab use. Heres my code:

function solution = RunODESolver(t, x, P, F_O2, F_Ar, tau_res)

options = odeset('RelTol', 1e-3);
%get the initial state...
dx = BigFunction(t,x,P,F_O2,F_Ar,tau_res);
%run the ODE...
[T,Y] = ode23tb(@(t, y) BigFunction(t,x,P,F_O2,F_Ar,tau_res), [0 10], dx, options);

solution = [T, Y];

Needless to say, this is not producing the result I was expecting - and I have a feeling it is something to do with the interaction between the ode and the BigFunction via the function handle? I've been banging my head against the help files for the last few hours but the examples listed there aren't very clear to me.

Any takers?
From: Steven Lord on

"Plank " <cougaris(a)gmail.com> wrote in message
news:hsuaq0$plp$1(a)fred.mathworks.com...
> Hey folks,
>
> I'm having some difficulty with syntax/understanding around the ODE
> functions. What I'm working on at the moment is a function, BigFunction(6
> parameters) that returns a 19 element answer. I then need to apply ode23tb
> to this answer for 10 steps - but I'm getting well hung up on the syntax
> for these things as well as my general lack of heavy matlab use. Heres my
> code:
>
> function solution = RunODESolver(t, x, P, F_O2, F_Ar, tau_res)
>
> options = odeset('RelTol', 1e-3);
> %get the initial state...
> dx = BigFunction(t,x,P,F_O2,F_Ar,tau_res);
> %run the ODE...
> [T,Y] = ode23tb(@(t, y) BigFunction(t,x,P,F_O2,F_Ar,tau_res), [0 10], dx,
> options);

Do you intend for BigFunction to have x as its second input argument even
though the anonymous function has y as its second input? That's the only
thing that jumps out at me right away as suspicious in the code you've
posted.

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