help-octave
[Top][All Lists]

## Re: Translating ODE from Matlab to Octave

 From: c. Subject: Re: Translating ODE from Matlab to Octave Date: Tue, 26 Nov 2013 16:42:25 +0100

```Hi,

On 26 Nov 2013, at 15:19, RICHARD Dominique <address@hidden> wrote:

> Hello everybody,
>   I am switching from Matlab to Octave and I got some code that I am not sure
> how to deal with.
> For example these lines:
>
> options = odeset('Mass',M);
> f = @(t,y) daesystem(t,y,params);
> [t,y] = ode15s(f,t,y0,options);
>
> which I transformed to :
>
> lsode_options
>       ('Mass',M);

I don't think "lsode_options" has an option called 'Mass',
have you looked at the help for lsode  or at the help for lsode in
the manual  before writing that command?
furthermore "ode15s" is often (although not exclusively) used to solve
Differential Algebraic Equations (DAE), i.e. ODEs with a singular mass matrix.
From that and from the fact that your function is named "daesystem" I infer
that
probably your problem is a system of DAEs.

If this is the case you should not be using lsode but rather daspk[5, 6]

Otherwise, if your mass matrix is not singular
you can just redefine

f = @(t,y) M \ daesystem(t,y,params);

to take the mass matrix into account.

> f = @(t,y) daesystem(t,y,params);
> [y,
>       t]= lsode(@(y,t) f, y0, t)

that is not the correct syntax for calling lsode,  and  will explain how
to use it.

>
> which does not seem to run properly.
>
> I had a look at the Octave notice but besides the definitions, I did not
> found clear enough examples for me to use.
do these examples [3, 4] help?

> I would be very grateful for any help to get me to the free side of software.

HTH,
c.

 type "help lsode" at the octave prompt to see the help

http://www.gnu.org/software/octave/doc/interpreter/Ordinary-Differential-Equations.html#Ordinary-Differential-Equations
 http://wiki.octave.org/Cookbook#Parametrized_Functions
 http://wiki.octave.org/Bim_package#3D_Time_dependent_problem
 type "help daspk" at the octave prompt to see the help

http://www.gnu.org/software/octave/doc/interpreter/Differential_002dAlgebraic-Equations.html#Differential_002dAlgebraic-Equations

```