title: How to optimize a lsqnonlin function, which I have already tried to optimize adding different options but still gives the same result?
body: <p>I have a set of parameters that I want to have them returned as result of the non-linear optimization through, the function <em>lsqnonlin</em>. The code is for an inverse problem, which gives a set of ThermoMechanical parameters in function of the displacement of a metallic bar. The problem, is that the optimization returns to me an aproximated value or almost the same as the starting point (X0). When it should be giving the result equal or aproximate to those of the variables. For that, I tried the input argument 'options', trying to change the number of MaxIter, MaxFunEval and the function tolerance. As a result of the program it alxays gives the same anszer:"<em>Optimization completed because the size of the gradient is less than
  the default value of the optimality tolerance.</em>" What can I do to improve the optimization? Thank you for your help.
      tf = 20;
      t=0:0.1:tf;</p>
  
  <pre><code>Texcel = xlsread ('Classeur(19_04).xls',1,'L2:L202');
  ResSpline = spline (t,Texcel);
  plot(t,ppval(mkpp(ResSpline.breaks,ResSpline.coefs),t));
  
  ParamThermMec;     %Thermo-mechanical parameters defined by the array X0=[coeff_dilat G Cp lanbda Rho]
  nu = 0.3;            %Poisson's coefficient
  Ucomsol = xlsread ('Classeur(19_04).xls',2,'L2:L202');     %displacement from Classeur(19_04).xls
  
  figure (1)
  hold on
  yyaxis left
  plot (t,Ucomsol)
  yyaxis right
  plot (t,Texcel)
  xlim([0 20])
  
  
  fun = @(X)(deplacement_lsq(0,ResSpline,X)-Ucomsol);         %function to minimize
  [temps,Umatlab_bauzin] = DeplacementSpline(0,ResSpline,1);
  plot(t,Umatlab_bauzin,'b',t,Ucomsol,'g');
  
  X0 = X/2;     %initial value or starting point
  
  options.TolFun=0.0000000000000000000000000000000000000001;
  [ParametresTM,resnorm,residual,exitflag,output]=lsqnonlin(fun,X0,[0 0 0 0 0],[10 999999999999 2500 500 4000],options);     %nonlinear minimisation                             
  DiffXP=X-ParametresTM;
  EX=[DiffXP(1)/X(1) DiffXP(2)/X(2) DiffXP(3)/X(3) DiffXP(4)/X(4) DiffXP(5)/X(5)]*100;     %Percentage difference
  </code></pre>