一小段程序,[0.15 0.17 0.09 0.019]中的第三个初始值为0.09时,运行程序出错,把0.09改为0.0900000001或0.08999999999都可以运行程序。出错信息为
错误使用 snls (line 47)
Objective function is returning
undefined values at initial point.
lsqnonlin cannot continue.
出错 lsqncommon (line 167)
snls(funfcn,xC,lb,ub,flags.verbosity,options,defaultopt,initVals.F,initVals.J,caller,
...
程序如下:
function linearr
clear all
close all
global t2 n
t=[0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8...
1.9 2.0];
n=[1.622630 1.545570 1.524481 1.514928 1.509274 1.505235 1.501924...
1.498930 1.496044 1.493147 1.490169 1.487064 1.483803 1.480363...
1.476729 1.472890 1.468834 1.464555 1.460044];
t2=t.*t;
options=optimset('TolFun',1e-8,'TolX',1e-8);
abcd=lsqnonlin(@iintensity,[0.15 0.17 0.09 0.019])
function oo1=iintensity(xx)
global t2 n
temp=xx(2)./(t2-xx(3));
oo1=xx(1)+temp+xx(4)*temp.*temp-n;