- 积分
- 0
- 注册时间
- 2009-9-4
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2012-4-14 20:43:03
|
显示全部楼层
来自 北京
至少要给个数据啊。
function f=examfun(p,x)
f=p(1)*exp(-((x-p(2))/p(3)).^2) + p(4)*exp(-((x-p(5))/p(6)).^2)+...
p(7)*exp(-((x-p(8))/p(9)).^2) + p(10)*exp(-((x-p(11))/p(12)).^2)+...
p(13)*exp(-((x-p(14))/p(15)).^2);
函数定义中变量之间要用点乘或者点除
clear;clc;
x0=[300,2,1,1900,5,2,-80,6,0,3900,9,3,800,3,1];
xdata=0:0.01:2*pi;
ydata=sin(xdata);
fun=@examfun
p=lsqcurvefit(fun,x0,xdata,ydata)
我给xdata ydata任意赋下值
??? Error using ==> snls at 259
lsqcurvefit cannot continue: user function is returning Inf or NaN values.
Error in ==> lsqncommon at 149
[xC,FVAL,LAMBDA,JACOB,EXITFLAG,OUTPUT,msgData]=...
Error in ==> lsqcurvefit at 258
[xCurrent,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
其他我就找不出来了 |
评分
-
1
查看全部评分
-
|