easy863 发表于 2009-4-20 17:17

求助程序报错原因

clc;
clear
%x1=X
x1=[0
0.010669284
0.027020242
0.038955138
0.050568534
0.073924154
0.084030671
0.09207069
0.103986707
0.115537725
0.125678672
    ];
%x2=ρl/ρg
x2=[329.5622031
329.2547127
328.7873177
328.3716765
327.9786586
327.2571568
326.9585471
326.7278941
326.4031234
326.0856043
325.8093758
    ];
x=;
%y=OR
y=[1
1.07535879
1.159502847
1.217346753
1.270863551
1.370033011
1.411412277
1.442283922
1.487442471
1.530420702
1.571592003
    ];
f=inline('(1+((x(:,2)).^n(1)+(1/x(:,2)).^n(2)).*x(:,1)+x(:,1).^2).^0.5','n','x');
n=nlinfit(x,y,f,)
yy=(1+((x(:,2)).^n(1)+(1/x(:,2)).^n(2)).*x(:,1)+x(:,1).^2).^0.5;
e=(yy-y)/y;
c=mean(e);
plot(x1,y,'b-',x1,yy,'r*')



很简单的一个小程序,就是想进行非线性拟合,得出一个方程模型的参数
运行后,报错信息为:
??? Error using ==> nlinfit at 114
The inline model function generated the following error:
Error using ==> inlineeval at 15
Error in inline expression ==>
(1+((x(:,2)).^n(1)+(1/x(:,2)).^n(2)).*x(:,1)+x(:,1).^2).^0.5
??? Error using ==> plus
Matrix dimensions must agree.
Error in ==> DeleeuwFit at 48
n=nlinfit(x,y,f,)

可是我的矩阵维数是相同的啊,请高手指点一下到底是怎么回事……
页: [1]
查看完整版本: 求助程序报错原因