登录论坛

查看完整版本 : [MATLAB基础] 报告matlab2018a的一个bug


intel80686
2020-11-01, 12:12
一小段程序,
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;
当第三个参数为0.09时运行出错,信息为:
错误使用 snls (line 47)
Objective function is returning undefined
values at initial point. lsqnonlin cannot
continue.
把0.09 作小小修改,即使是0.0900001,也可以正常运行。