From maintainers-request at octave dot org Sun Feb 6 16:48:20 2005 Subject: fsolve Patch for Function Handles From: Todd Neal To: maintainers at octave dot org Date: Sun, 6 Feb 2005 17:52:01 -0500 I was looking at the following page http://www.mathworks.com/access/helpdesk/help/toolbox/optim/fsolve.html and couldn't get this example to work in Octave: octave:1> x0=2 x0 = 2 octave:2> x = fsolve( at (x)sin(x dot *x),x0) error: value on right hand side of assignment is undefined error: evaluating assignment expression near line 2, column 3 I checked and fsolve was not handling parameters that were function handles correctly, I modified it and it seems to work fine. octave:1> x0=2 x0 = 2 octave:2> x = fsolve( at (x)sin(x dot *x),x0) x = 1.7725 I haven't looked at the code to Octave much in depth so there may be a better way to do this or other repercussions from this patch. Todd *** a/fsolve.cc 17 Nov 2003 20:19:07 -0000 1.25 --- b/fsolve.cc 6 Feb 2005 22:40:10 -0000 *************** parameters for at code{fsolve} dot \n\ *** 261,266 **** --- 261,270 ---- octave_value f_arg = args(0); + if (f_arg.is_function_handle()) { + fsolve_fcn = f_arg.function_value(); + } + switch (f_arg.rows ()) { case 1: