[求助]求大侠指导这个nlinfit拟合可行否
x=;aveW=sum(th(4:57,1))/nx;aveS=sum(th(4:57,2))/nx;
b0=[ aveW^2 1 0.5 aveWaveS 1];
myfunc=inline('beta(1)*(x(:,1)+x(:,2)*beta(2)+x(:,3)*beta(2)^2+x(:,4)*beta(3)+x(:,5)*beta(3)^2+x(:,6)*beta(3)^3)^2+ beta(4)*(x(:,1)+x(:,2)*beta(2)+x(:,3)*beta(2)^2+x(:,4)*beta(3)+x(:,5)*beta(3)^2+x(:,6)*beta(3)^3)+ beta(5)x(:,7)+beta(6)*x(:,8)','beta','x');
b=nlinfit(x,p,myfunc,b0);
t1,t2等都是54*1的列向量,我试图用ninfit来拟合 结果报错如下
??? Error using ==> nlinfit
The inline model function generated the following error:
Error using ==> inlineeval
Error in inline expression ==> beta(1)*(x(:,1)+x(:,2)*beta(2)+x(:,3)*beta(2)^2+x(:,4)*beta(3)+x(:,5)*beta(3)^2+x(:,6)*beta(3)^3)^2+beta(4)*(x(:,1)+x(:,2)*beta(2)+x(:,3)*beta(2)^2+x(:,4)*beta(3)+x(:,5)*beta(3)^2+x(:,6)*beta(3)^3)+beta(5)x(:,7)+beta(6)*x(:,8)
??? Error: Unexpected MATLAB expression.
Error in ==> erci at 40
b=nlinfit(x,p,myfunc,b0);
要拟合的方程有点长,求大虾指导我哪里弄错了?或者说nlinfit能否做这样的拟合?不行的话matlab还要其他什么命令能做到的?
再问一件事情呵呵,在这里常看到有什么说拟合用1stOpt拟合,这个软件貌似都是收费的吗?
式子有点长,问题也有点多,请各位多多指教啦,最近要用到刚这个头都大了,先谢过了
回复 楼主 hrainbow 的帖子
beta(5)x(:,7)之间少了个“*”.另外用inline时不知道x(:,1)这种形式是合适的吗? x的形式是可以的 前面做一次拟合时能行的现在加了*号了 编译还有问题
??? Error using ==> nlinfit
The inline model function generated the following error:
Error using ==> inlineeval
Error in inline expression ==> beta(1)*(x(:,1)+x(:,2)*beta(2)+x(:,3)*beta(2)^2+x(:,4)*beta(3)+x(:,5)*beta(3)^2+x(:,6)*beta(3)^3)^2+beta(4)*(x(:,1)+x(:,2)*beta(2)+x(:,3)*beta(2)^2+x(:,4)*beta(3)+x(:,5)*beta(3)^2+x(:,6)*beta(3)^3)+beta(5)*x(:,7)+beta(6)*x(:,8)
??? Error using ==> mpower
Matrix must be square.
Error in ==> erci at 40
b=nlinfit(x,p,myfunc,b0);
谢谢啦呵呵我自己都没看出来 再次谢谢啦,拟合出来了呵呵,大括号后面的^2应该是.^2,
原来这样也能拟合的,我还担心不行呢,看了我得细心点啊 再来问下matlab里边单行程序分行写是这样吗
myfunc=inline('beta(1)*(x(:,1)+x(:,2)*beta(2)+x(:,3)*beta(2)^2+x(:,4)*beta(3)+x(:,5)*beta(3)^2+x(:,6)*beta(3)^3)^2 ...
+ beta(4)*(x(:,1)+x(:,2)*beta(2)+x(:,3)*beta(2)^2+x(:,4)*beta(3)+x(:,5)*beta(3)^2+x(:,6)*beta(3)^3) ...
+ beta(5)x(:,7)+beta(6)*x(:,8)','beta','x');
我编译不行啊?
回复 5楼 hrainbow 的帖子
myfunc=inline(['beta(1)*(x(:,1)+x(:,2)*beta(2)+x(:,3)*beta(2)^2+x(:,4)*beta(3)+x(:,5)*beta(3)^2+x(:,6)*beta(3)^3)^2', ...'+ beta(4)*(x(:,1)+x(:,2)*beta(2)+x(:,3)*beta(2)^2+x(:,4)*beta(3)+x(:,5)*beta(3)^2+x(:,6)*beta(3)^3)', ...
'+ beta(5)x(:,7)+beta(6)*x(:,8)'],'beta','x');
这样试试
页:
[1]