Re: lsode

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: lsode

John Eaton-3
On  Thu, 24 Jun 93 22:18:00 +0700, [hidden email]
(Sigfrid Lundberg) wrote:

: I'm a newbie octave user. Everything seem to work as expected, but there
: is one I don't understand. I have written a tiny function:
:
: function xdot = volterra ( x , t)

:  global x xdot;

There's no need to declare these variables as global.

: Then I start octave, and load this function:

: octave:1> eval("volterra");
: error: `x' undefined

There's no need to use eval here -- just asking for a function
evaluation will work just fine.  It's also not necessary to ask for a
function evaluation before calling lsode (but I often do, just to see
if the function actually does work).

: But, if I try to use lsode for solving this predator-prey model
:
: octave:19> lsode ('volterra',x,30,0.01)
:
: nothing interesting happens. What am I doing wrong?

You need to specify a vector for t_out, including the time
corresponding to the initial condition.

The t_crit parameter is probably not useful here -- it's there so you
can tell lsode not to integrate past certain points (usually
discontinuities in the RHS function).

Try something like:

  t = (0:0.5:100)';
  y = lsode ('volterra', x, t);
  plot (t, y);                  # look at behavior in time
  plot (y(:,1), y(:,2));        # look at phase portrait too

I found that x = [1; 2] was an interesting starting condition.


I see that the help message isn't very helpful, and that there isn't
much documentation either.  Hmmm.  Someone should do something about
that.  :-).

--
John W. Eaton      | Among other things, we have added the missing semicolon.
[hidden email] |                   -- Jim Blandy, announcing Emacs 19.15.