Warning: Rank deficient, rank = 0, tol = NaN.

1 visualización (últimos 30 días)
Sitra
Sitra el 15 de Ag. de 2018
Comentada: Sitra el 15 de Ag. de 2018
Hi Dears,
I'm using lsqcurvefit to fit my data. Sometimes, when I select an initial guess I get the following error:
Warning: Rank deficient, rank = 0, tol = NaN.
My question is not about how to fix that error. Rather, I hope to see how to avoid that fitting process entirely when it detects that error!
I mean, suppose the curve fitting (using lsqcurvefit or any other optimization tool; such as: NonLinearModel.fit, etc) is located in a function that is called via a main m-file. If the previous warning is detected, then the m-file should ignore or bypass that function and proceeds normally without stopping the program on a red error message says: Error using lsqcurvefit (line 251) Function value and YDATA sizes are not equal.
All what I need is like an if-statement. If the initial guess is healthy then please fit the data; otherwise, ignore the curve fitting stage and jump to the next lines in the main m-file.
Could you please guide me in resolving this issue.
Thank you so much

Respuesta aceptada

Bjorn Gustavsson
Bjorn Gustavsson el 15 de Ag. de 2018
Have a look at
try
catch
end
That way you might be able to put the curve fitting (or other fragile attempts) in the try part and handle the occasional errors in the catch part.
HTH
  1 comentario
Sitra
Sitra el 15 de Ag. de 2018
Awesome
Great trick and it solves my problem
Thank you so much

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Least Squares en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by