0

i've a problem to understand this snippet of code

output=lsqnonlin(@(argn) fun(arg1,arg2,argn),X0);

My idea is that lsqnonlin will call the argn->fun function recursively,but i'm not sure. is it right?

RobCos
  • 113
  • 10

1 Answers1

2

It is impossible to say what lsqnonlin will do without the functions' code. However, there is nothing inherently recursive in the function call in your question.

The 1st argument to lsqnonlin is a function handle, and in the function call in your question, you pass an anonymous function handle:

@(argn) fun(arg1,arg2,argn)

Which is a function with one argument to be used by the function, argn, and two parameters (are pre-set arguments), arg1 and arg2. lsqnonlin uses the function handle you pass it in order to calculate the function value in a specific point or vector of points.

You can read more about anonymous function handle here: http://www.mathworks.com/help/techdoc/matlab_prog/f4-70115.html#f4-70133

Itamar Katz
  • 9,544
  • 5
  • 42
  • 74
  • 1
    For your reference: [lsqnonlin](http://www.mathworks.com/help/toolbox/optim/ug/lsqnonlin.html) – Jonas Jan 27 '11 at 16:41