![]() |
各位大神,帮帮忙!一个有关最小二乘拟合的问题。
问题是这样的,现在需要将[IMG]http://www.ilovematlab.cn/data/attachment/forum/201203/29/141202pfpp2bk9o9y8wpb6.jpg[/IMG]这个函数加一些噪声进去,然后再用[IMG]http://www.ilovematlab.cn/data/attachment/forum/201203/29/14131555yzrp4ptzyyw75a.jpg[/IMG]进行拟合,观察系数a1a2a3。现在噪声暂时还没有添加,程序如下
clear all clf x=-120:1:120;%x的取值范围 N=length(x);%x的向量长度 %A=(pi/1.54)-(pi/1.56)=0.0262; y=((0.0262*x).^-1).*sin(0.0262*x);%产生y plot(x,y) f=inline('a(1)*((0.0262*(x-a(2))).^-1).*sin(0.0262*(x-a(2)))+a(3)','a','x'); [xx,res]=lsqcurvefit(f,[1,0,0],x,y); xx',res 运行一直不成功,返回下列结果 ??? Error using ==> optim\private\snls lsqcurvefit cannot continue: user function is returning Inf or NaN values. Error in ==> optim\private\lsqncommon at 222 [x,FVAL,LAMBDA,JACOB,EXITFLAG,OUTPUT,msg]=... Error in ==> lsqcurvefit at 149 [x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ... 请问下这个的问题大概在哪里?应该怎么改?请帮我看看,非常感谢!!!! |
所有时间均为北京时间。现在的时间是 12:36。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.