help-octave
[Top][All Lists]
Advanced

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

Re: passing parameters to lsode


From: Søren Hauberg
Subject: Re: passing parameters to lsode
Date: Thu, 27 Sep 2007 08:04:46 +0200
User-agent: Thunderbird 1.5.0.13 (X11/20070824)

address@hidden skrev:
Hi -
this is my first message here. Hope I do this right ;) Question: How do I pass parameters to a differential equation? lsode wants me to declare the diff. eq. as function xdot = something(x,t). i would rather like to declare this as xdot=something(x,t,parameter1,...). I help myself by declaring global variables for every parameter. This doesn't look very elegant and transparent to me.
Welcome to the list :-)
I don't remember exactly how to call 'lsode', but the answer to your question is to create a local function. That is, you can do something like this:

  a = 2; b = 1;
  f = @(x, t) sin(a*x + b);
  lsode(f, 0, linspace(0, 5, 20))

Does that help/make sense?

Søren


reply via email to

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