sakurain 发表于 2009-3-22 22:30

nlinfit非线性函数拟合报错求助

在用nlinfit进行非线性函数的拟合中,总是报错。需要拟合的函数有些复杂,我的m程序为:
function nlfm(x,y,beta0)
beta=nlinfit(x,y,@modle,beta0);
function yy=modle(beta0,x)      
a=beta0(1);
b=beta0(2);
c=beta0(3);
x1=x(:,1);
x2=x(:,2);
x3=x(:,3);
x4=x(:,4);
x5=x(:,5);
x6=x(:,6);
x7=x(:,7);
x8=x(:,8);
x9=x(:,9);
x10=x(:,10);
x11=x(:,11);
x12=x(:,12);
yy=inline('log(x1.*exp(beta0(1)*x5+beta0(2)*x11+beta0(3)*x9)+x2.*exp(beta0(1)*x6+beta0(2)*x11+beta0(3)*x9))-log(x3.*exp(beta0(1)*x7+beta0(2)*x12+beta0(3)*x10)+x4.*exp(beta0(1)*x8+beta0(2)*x12+beta0(3)*x10))','beta0','x');

在命令栏调用nlfm函数,就报出下面的错误:
>> nlfm(x,y,beta0)
??? Error using ==> nlinfit at 127
MODELFUN should return a vector of fitted values the same length as Y.
Error in ==> nlfm at 2
beta=nlinfit(x,y,@modle,beta0);

也上网查了查,但是没有找到行得通的解决办法。在m文件中,最初写的x1、x2后面并没有加.号,是看了一些解决方法加了之后试了试还是报同样的错误。希望高人指点!!!时间比较紧,在线等,希望大家多多指教!

[ 本帖最后由 sakurain 于 2009-3-22 22:40 编辑 ]
页: [1]
查看完整版本: nlinfit非线性函数拟合报错求助