Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.

118 ビュー (過去 30 日間)
raw = xlsread('File', 2); % read in sheet number 2
Pc = raw(60:141, 1);
Sw = raw(60:141, 9);
plot(Sw,Pc,'ro')
F = @(x,xdata)1-x(1)*exp(-(x(2)/xdata)^(x(3)));
x0 = [3 6 0.6];
[x,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,Sw,Pc)
I keep getting this error.
Error in Skelt_LS_Code (line 16)
[x,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,Sw,Pc)
Caused by:
Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.
Any help is appreciated. Thank you

採用された回答

Walter Roberson
Walter Roberson 2020 年 1 月 6 日
F = @(x,xdata)1-x(1)*exp(-(x(2)./xdata).^(x(3)));
  6 件のコメント
Thi Na Le
Thi Na Le 2020 年 2 月 27 日
ydata in previous reply was wrong. this is modification:
a0=4;
xdata=...
[5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180];
ydata=...
[0.04178 0.081 0.09475 0.1157 0.1326 0.1468 0.1587 0.169 0.178 0.186 0.193 0.199 0.205 0.211 0.215 0.22 0.224 0.229 0.233 0.238 0.242 0.245 0.248 0.251 0.254 0.257 0.258 0.261 0.264 0.266 0.269 0.272 0.274 0.277 0.273 0.275];
fun=@(x,xdata)a0*(1+((4.5*x(1)*x(2)*xdata)/(5.5+x(2)*xdata)));
x0=[0.01 0.0001];
>> plot(xdata,ydata,'o')
>> x = lsqcurvefit(fun,x0,xdata,ydata)
Error using lsqcurvefit (line 262)
Function value and YDATA sizes are not equal.
Walter Roberson
Walter Roberson 2020 年 2 月 27 日
You need ./ instead of /

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

その他の回答 (1 件)

Alex Sha
Alex Sha 2020 年 1 月 7 日
Hi,Thaer Ismail, which is your exact fit function: "ydata=1-x1*exp(-(x2/xdata)^x3)" or "ydata=1-x1*exp((-x2/xdata)^x3)" ?
if the former, take initial start values as:
x0 = [-23124 0.3 -2.2];
c245.jpg
  1 件のコメント
Thaer Ismail
Thaer Ismail 2020 年 1 月 7 日
It is actually the former.
I tried the initial guesses that you graciously provided but still get a very bad fit.
Thank you.skelt bad 3.JPG

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

カテゴリ

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

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by