声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 797|回复: 0

[编程技巧] 求助程序报错原因

[复制链接]
发表于 2009-4-20 17:17 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
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=[x1 x2];
%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,[1,1])
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,1])

可是我的矩阵维数是相同的啊,请高手指点一下到底是怎么回事……
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-22 15:44 , Processed in 0.061246 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表