[Top][All Lists]

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

Re: Passing parameters to fsolve function - new syntax?

From: Paul Kienzle
Subject: Re: Passing parameters to fsolve function - new syntax?
Date: Wed, 5 Oct 2005 06:40:46 -0400


        function y=f(x,a,b,c), y = a*x.^2+b*x+c; end

you should be able to call:


and have it return -1.

This didn't work on my system (2.1.71 for OS X).  The following does:


Defining fa(x) = f(x,1,-2,-3)

        function y=fa(x), y=f(x,1,-2,-3); end

I can call


and get an answer of -1.  I cannot call


and get any answer.

Looking at the source to src/DLD-FUNCTIONS/ and src/, it looks like extract_function will only look for functions defined by string name.

The fix in extract_function would be something like:

  octave_function *retval = 0;

  if (! arg.is_string())
      retval = arg.function_value ();
      if (! fcn)
error ("%s: expected string or function handle", warn_for.c_str ());
       ... current extract_function body
  return retval;

On Oct 5, 2005, at 4:27 AM, Aivo Jürgenson wrote:


I have a function f(x,a,b,c), which I would like solve for variable x, so that f(x,a,b,c)=0, where a,b,c are parameters, which are known at the time of solving.

However, current fsolve function in Octave only supports one-variable functions. I suppose there is a work-around to declare specific global variables and then giving values to those variables before calling the fsolve function, but this doesn't seem to be a clean way of organizing this.

The fsolve FIX in the octave-forge package seems to expand this functionality, but I'm not able to compile it. Also, the status of this FIX seems to be unclear, as in the development mailing list message

Paul Kienzle, in May, 2005:

I have no interest in maintaining this function. I am removing it from
the build system for now, and will purge it completely if nobody steps
forward to update it.

IIRC, the purpose of this function is to pass extra arguments to
fsolve, but we can do this now with the new syntax:

        @(x) f(x,a,b,c)

- Paul

Could somebody explain this new syntax? I would be happy to use this new and official way of passing extra arguments to fsolve, but I'm not been able to find any examples of doing it.

Aivo Jürgenson, address@hidden

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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