[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lsode
From: |
John Eaton |
Subject: |
Re: lsode |
Date: |
Thu, 24 Jun 93 19:42:53 EDT |
On Thu, 24 Jun 93 22:18:00 +0700, address@hidden
(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.
address@hidden | -- Jim Blandy, announcing Emacs 19.15.
- lsode, Sigfrid Lundberg, 1993/06/24