Continue program after exponential fit gives inf

1 回表示 (過去 30 日間)
Ninad Chitnis
Ninad Chitnis 2020 年 5 月 22 日
コメント済み: Ninad Chitnis 2020 年 5 月 22 日
I have a few sets of exponentially increasing curves. I need to plot the growth rate of these curves. I am using
f1 = fit(X_axis_data, curve_envelope, 'exp1');
This is run in a double foor loop with outer loop indexing different sets of the curves and inner loop parsing through each curve in a set. Now I know that the rate is increasing so eventually I will get NaN from the exp fit. But the script throws an error
Error using fit>iFit (line 348)
Inf computed by model function, fitting cannot continue.
Try using or tightening upper and lower bounds on coefficients.
But I want to move to the next iteration of the outer loop when exp fit gives NaN. Can someoene help?

採用された回答

darova
darova 2020 年 5 月 22 日
Use try and catch
for i = 1:10
try
f1 = fit(X_axis_data, curve_envelope, 'exp1');
catch ME
disp('error')
end
end
  1 件のコメント
Ninad Chitnis
Ninad Chitnis 2020 年 5 月 22 日
That worked, thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by