Does lsqnonlin handle a matrix objective function?

3 views (last 30 days)
How does lsqnonlin handle a matrix?
assuming something like
[Final_Ests,resNormal] = lsqnonlin(LSQ_obj_fnctn,initialGuess,LB,UB);
will the results be the same if LSQ_obj_fnctn is a matrix vs being a single vector made up of matrix rows?
i.e. matrix:
LSQ_obj_fnctn = rand(4,10)
vs. vector made up of matrix rows
LSQ_obj_fnctn = rand(1,40)
To be clear, I'm not actually trying to minimize a randomly generated matrix or vector, just trying to show an example of the form of what I'm passing to lsqnonlin. My results seem to indicate both matrix and vector objective functions give the same result, but I just want to be triple sure I'm not misunderstanding something.
Thanks!

Answers (1)

Matt J
Matt J on 17 Mar 2024
Edited: Matt J on 17 Mar 2024
The matrix dimensions of the objective function output can be whatever you wish. It doesn't affect anything. The initialGuess can also be array-valued, although there are bugs in that feature in older versions.
Note that a closely related function lsqcurvefit,
can also have matrix-valued fun, but the ydata argument must have the same matrix dimension.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!