help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ode23


From: Mohsin Mohd Sies
Subject: Re: ode23
Date: Thu, 6 Dec 2018 12:54:34 +0800

In addition, I just noticed another weird error of the ode23 function. I followed the example given in https://octave.org/doc/v4.4.1/Ordinary-Differential-Equations.html, specifically

Here is an example of solving a set of three differential equations using lsode. Given the function

## oregonator differential equation
function xdot = f (x, t)

  xdot = zeros (3,1);

  xdot(1) = 77.27 * (x(2) - x(1)*x(2) + x(1) ...
            - 8.375e-06*x(1)^2);
  xdot(2) = (x(3) - x(1)*x(2) - x(2)) / 77.27;
  xdot(3) = 0.161*(x(1) - x(3));

endfunction

and the initial condition x0 = [ 4; 1.1; 4 ], the set of equations can be integrated using the command

t = linspace (0, 500, 1000);

y = lsode ("f", x0, t);
lsode ran as expected as per below;

octave:7> function xdot = f (x, t)
>
>   xdot = zeros (3,1);
>
>   xdot(1) = 77.27 * (x(2) - x(1)*x(2) + x(1) ...
>             - 8.375e-06*x(1)^2);
>   xdot(2) = (x(3) - x(1)*x(2) - x(2)) / 77.27;
>   xdot(3) = 0.161*(x(1) - x(3));
>
> endfunction
octave:8> x0 = [ 4; 1.1; 4 ];
octave:9> t = linspace (0, 500, 1000);
octave:10>
octave:10> y = lsode ("f", x0, t);
octave:11>
octave:11>

But when I tried it using ode23, it gave an error (I have exchanged the position of trange and x0 as needed between lsode and ode23 as required)

octave:11> y = ode23 ("f", t, x0);
error: x(2): out of bound 1
error: called from
    f at line 5 column 11
    starting_stepsize at line 46 column 5
    ode23 at line 192 column 25
octave:11>

Regards.

On Thu, Dec 6, 2018 at 11:58 AM Mohsin Mohd Sies <address@hidden> wrote:
Hmmm, on second look, it seems that it is under odepkg which is now bundled with the standard Octave? Am I correct? 

On Wed, 5 Dec 2018, 21:33 Carlo De Falco <address@hidden wrote:


> On 5 Dec 2018, at 09:47, mochzeen <address@hidden> wrote:
>
> Hi,
>
> I have installed the latest Octave 4.4.1 which includes ode23. When I tried
> my old ode example code which worked previously, it gave me an error of
>
> error: structure has no member 'OutputSave'
> error: called from
>    ode23 at line 166 column 3
>
> My code is vdpol.m
> trange=[0 0.5];
> x0=[1;0];
> ode23(@myproblemm,trange,x0)
>
> with myproblemm.m
> function dxdt=myproblemm(t,x)
> dx1dt=x(2);
> dx2dt=5-3*x(2)-x(1);
> dxdt=[dx1dt; dx2dt];
>
> I Googled the error message but no luck. Please help.



Hi,

I cannot reproduce your issue, your example works for me with no error ...

Are you using ode23 form odepkg or the built-in implementation?
What do you see if you type "pkg list, which ode23"?

c.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]