【培训通知】2013年MCM优秀论文精读培训 中国数模界最第一大专业科技 (www.madio.net)数学中国 数学建模思想方法大全精讲专题 第数学建模思想方法大全精讲专题 数学建模精品资源课程系列 国内专业的数学建模实训 如题,利用lsqcurvefit和lsqnonlin两个函数进行非线性拟合,总是提前收敛,求大神解释为什么?是否是更改里面的options选项,具体怎么改?在线等,万谢。。。 1、程序代码如下: 1)编写M-文件 curvefun1.m function f=curvefun1(x,tdata) f=1-exp(-6.908*(((tdata-x(1))./x(2)).^x(3))); %其中 x(1)=cb; x(2)=cb-cc;x(3)=m+1; 2)输入命令 tdata=[………]; ydata=[………]; x0=[-10,55,2]; [x,resnorm] =lsqcurvefit('curvefun1',x0,tdata,ydata) f= curvefun1(x,tdata); 3) 结果 Local minimum possible. lsqcurvefit stopped because the finalchange in the sum of squares relative to its initial value is less than the defaultvalue of the function tolerance. x = Columns 1 through 2 -3.59020088832205 - 0.62244270778384i 53.9542595923814 + 0.14425192684233i Column 3 2.69114674932468 + 0.0818892331391404i resnorm = 0.00627209364358831 2、函数介绍如下: 1)函数 lsqcurvefit 2)格式 x = lsqcurvefit(fun,x0,xdata,ydata) x =lsqcurvefit(fun,x0,xdata,ydata,lb,ub) x =lsqcurvefit(fun,x0,xdata,ydata,lb,ub,options) [x,resnorm] = lsqcurvefit(…) [x,resnorm,residual] = lsqcurvefit(…) [x,resnorm,residual,exitflag] =lsqcurvefit(…) [x,resnorm,residual,exitflag,output]= lsqcurvefit(…) [x,resnorm,residual,exitflag,output,lambda]= lsqcurvefit(…) [x,resnorm,residual,exitflag,output,lambda,jacobian]=lsqcurvefit(…) 3)参数说明: x0为初始解向量;xdata,ydata为满足关系ydata=F(x, xdata)的数据; lb、ub为解向量的下界和上界,若没有指定界,则lb=[ ],ub=[ ]; options为指定的优化参数; fun为拟合函数,其定义方式为:x = lsqcurvefit(@myfun,x0,xdata,ydata), 其中myfun已定义为 function F = myfun(x,xdata) F = … % 计算x处拟合函数值fun的用法与前面相同; resnorm=sum ((fun(x,xdata)-ydata).^2),即在x处残差的平方和; residual=fun(x,xdata)-ydata,即在x处的残差; exitflag为终止迭代的条件; output为输出的优化信息; lambda为解x处的Lagrange乘子; jacobian为解x处拟合函数fun的jacobian矩阵。 |
欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |