Warning: Rank deficient, rank = 0, tol = NaN.
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Bjorn Gustavsson
2018-8-15
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Least Squares 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!