Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.

122 次查看(过去 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.

请先登录,再进行评论。

更多回答(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

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by