Error with lsqnonlin : Error in lsqncommon (line 14) if any(~isfinite(initVals.F))
Show older comments
Hello everybody,
I have a question : when I run my programm, I have an error in lsqncommon. So I went in this function to understand my error and the programm stop at this line of the function lsqncommon :
if any(~isfinite(initVals.F))
error(message('optimlib:commonMsgs:UsrObjUndefAtX0', caller));
end
But I don't understand the meaning of this line, is there someone who can explain me this line please ?
Thanks !
Franck
Accepted Answer
More Answers (1)
Franck Farail
on 26 Jul 2021
0 votes
5 Comments
Alan Weiss
on 26 Jul 2021
Please show the call to lsqnonlin.
Please show the entire error, every single red line.
Please show the values of your arguments, including at least the first line of your nonlinear function.
Alan Weiss
MATLAB mathematical toolbox documentation
Franck Farail
on 26 Jul 2021
Alan Weiss
on 26 Jul 2021
If you evaluate
fonction_erreur(x0)
you will most likely get an error. This error is the one to fix.
If you don't get an error, then you will probably obtain some strange values of the function, such as characters or some other data type. The function must return double values only.
Alan Weiss
MATLAB mathematical toolbox documentation
Franck Farail
on 27 Jul 2021
Alan Weiss
on 27 Jul 2021
It looks like you are mixing up cell arrays and matrices. This line creates a matrix:
erreur_pose = zeros(100,100);
Then you try to refer to it using cell array indexing:
erreur_pose{j,1} = Pos_M{j,1} - Pos_F{j,1};
I don't know what type of variable Pos_M is (or Pos_F either), whether it is a matrix or a cell array. Assuming that it is a matrix, you should write
erreur_pose(j,1) = Pos_M(j,1) - Pos_F(j,1);
Then again, I don't see a loop here defining the indices j and i. Nor do I see a need for any such indices. Maybe you shoud write
erreur_pose = Pos_M - Pos_F;
I really cannot understand your function, either what it is or what it is trying to accomplish. But this indexing suggestion should help.
Alan Weiss
MATLAB mathematical toolbox documentation
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!