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

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

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

More Answers (1)

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 Comments

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
opts = optimoptions('lsqnonlin','Algorithm','levenberg-marquardt');
x0 = 3.92699081698724 1.20000000000000 0.300000000000000 3.37745703122409 0
2.35619449019235 2.30000000000000 1.40000000000000 3.21163801526966 0
1.57079632679490 0.100000000000000 3.26000000000000 0.143811735939238 0.523598775598299
0.785398163397448 0.0300000000000000 2.14000000000000 1.27939824687061 0
1.78539816339745 3.15000000000000 0.0200000000000000 0.177638833777887 0
3.92699081698724 1.26000000000000 0.0300000000000000 0.00682008492641159 0;
[param_identifies] = lsqnonlin(@fonction_erreur,x0,[],[],opts);
Error :
Check for missing argument or incorrect argument data type in call to function 'isfinite'.
Error in lsqncommon (line 14)
if any(~isfinite(initVals.F))
Error in lsqnonlin (line 260)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,optimgetFlag,caller,...
Error in Etalonnage_robot_6R (line 224)
[param_identifies] = lsqnonlin(@fonction_erreur,x0,[],[],opts);
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
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
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

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!