Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.

122 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Jan. 2020
F = @(x,xdata)1-x(1)*exp(-(x(2)./xdata).^(x(3)));
  6 Kommentare
Thi Na Le
Thi Na Le am 27 Feb. 2020
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Alex Sha
Alex Sha am 7 Jan. 2020
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 Kommentar
Thaer Ismail
Thaer Ismail am 7 Jan. 2020
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

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by