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:27:12 +0200
User-agent: Thunderbird 1.5.0.13 (X11/20070824)


address@hidden skrev:
[Sorry for posting that way (I have to use a web client, hopefully the
html-style is disabled now)].
Quite al right :-)

 Thank you, but that's not what I want. The function definition for f
sits in an .m-file. I do not want to "hide" the parameters to the
outside. It should be clear (made transparent) that the parameters,
which are declared in the main program, are used in solving the diff.
eq. With global variables this becomes obscure. It would be nice to pass
those parameters from the main program to lsode which then evaluates
them by calling f.
If I understand you correctly you can do this using the approach I suggested (although I wasn't very clear). Lets assume that the file f.m
contains a function defined like this

function retval = f(x, t, a, b)
  ## Do stuff
endfunction

You can then pass the parameters 'a' and 'b' to 'lsode' like this

  a = 1; b = 2;
  g = @(x,t) f(x, t, a, b);
  lsode(g, x_0, t)

This is the standard solution to your problem. (But perhaps I'm misunderstanding you)

Søren


reply via email to

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