Error with lsqnonlin : Error in lsqncommon (line 14) if any(~isfin​ite(initVa​ls.F))

6 vues (au cours des 30 derniers jours)
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

Réponse acceptée

Alan Weiss
Alan Weiss le 6 Avr 2021
Apparently, some initial values are not finite. You gave a value of x0 so that your objective function evaluated at x0 gives some NaN or Inf value. The solver cannot proceed from such a point.
Alan Weiss
MATLAB mathematical toolbox documentation

Plus de réponses (1)

Franck Farail
Franck Farail le 26 Juil 2021
Hello everybody,
So I ckecked my programm and I don't understand : I checked my initials values to see if they are finite and they are finite and then wenn I put these values in the lsqnonlin function, I have the same error.
TF =
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1 Finite value
Check for missing argument or incorrect argument data type in call to function 'isfinite'.
Error in lsqncommon (line 14)
if any(~isfinite(initVals.F))
  5 commentaires
Franck Farail
Franck Farail le 27 Juil 2021
Okay so I evaluate the function
fonction_erreur(x0)
I changed some things and now I have this error message
Unable to perform assignment because brace indexing is not supported for variables of this type.
Error in fonction_erreur (line 20)
erreur_pose{j,1} = Pos_M{j,1} - Pos_F{j,1};
Error in Etalonnage_robot_6R (line 201)
fonction_erreur(DHM_e);
Here is my function :
function erreur = fonction_erreur(dhm_e)
global Routil Poutil Pos_F Pos_M j;
erreur_pose = zeros(100,100);
T06_e = calc_mgd(dhm_e);
disp('T06_e =');
disp(T06_e);
%Tb = matrice_passage_instrument(DHMolt1);
To = matrice_passage_outil_cas_2(Routil,Poutil);
Pos_M{j,1} = T06_e*To; %Tb
disp('Pos_M =');
disp(Pos_M);
erreur_pose{j,1} = Pos_M{j,1} - Pos_F{j,1};
save erreur_de_positions erreur_pose
save positions_finales_mesurées Pos_M
erreur = erreur_pose;
end
Alan Weiss
Alan Weiss le 27 Juil 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

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by