声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1492|回复: 2

[编程技巧] 求助,这程序哪出问题了?

[复制链接]
发表于 2006-12-1 10:33 | 显示全部楼层 |阅读模式

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

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

x
>> x=[0 0.0393 0.062 0.0802 0.0971 0.1186 0.1388 0.166 0.2176 0.2689 0.3228 0.3977 0.4611 0.5446 0.6236 0.7379 0.8406 0.8658 0.8743]
y=[-71.525        8.1722e+005        1.2109e+006        1.6137e+006        1.9864e+006        2.3373e+006        2.9319e+006        3.8018e+006        4.3019e+006        4.7963e+006        5.3595e+006        5.7329e+006        6.0958e+006        6.2835e+006        6.3516e+006        6.2852e+006        6.3562e+006        6.4678e+006        6.6246e+006]
fun=inline('(x^2*0.0751+0.6192*x*(1-x)*(1-K(2))+(1-x)^2*0.5442)+(x^2*27.5511+2*x*(1-x)*(2.3716e+004)^0.5*(1-K(1))+(1-x)^2*860.8071)*(x^2*0.0751+2*x*(1-x)*(0.3096*(1-K(2)))+(1-x)^2*0.5442)/((2^0.5)*R*T)','K','x')
K0=[0.5 0.5];
K=lsqcurvefit(fun,K0,x,y)

x =

  Columns 1 through 8

         0    0.0393    0.0620    0.0802    0.0971    0.1186    0.1388    0.1660

  Columns 9 through 16

    0.2176    0.2689    0.3228    0.3977    0.4611    0.5446    0.6236    0.7379

  Columns 17 through 19

    0.8406    0.8658    0.8743


y =

  1.0e+006 *

  Columns 1 through 8

   -0.0001    0.8172    1.2109    1.6137    1.9864    2.3373    2.9319    3.8018

  Columns 9 through 16

    4.3019    4.7963    5.3595    5.7329    6.0958    6.2835    6.3516    6.2852

  Columns 17 through 19

    6.3562    6.4678    6.6246


fun =

     Inline function:
     fun(K,x) = (x^2*0.0751+0.6192*x*(1-x)*(1-K(2))+(1-x)^2*0.5442)+(x^2*27.5511+2*x*(1-x)*(2.3716e+004)^0.5*(1-K(1))+(1-x)^2*860.8071)*(x^2*0.0751+2*x*(1-x)*(0.3096*(1-K(2)))+(1-x)^2*0.5442)/((2^0.5)*R*T)

??? Error using ==> optim\private\lsqncommon
User supplied expression or inline function ==> (x^2*0.0751+0.6192*x*(1-x)*(1-K(2))+(1-x)^2*0.5442)+(x^2*27.5511+2*x*(1-x)*(2.3716e+004)^0.5*(1-K(1))+(1-x)^2*860.8071)*(x^2*0.0751+2*x*(1-x)*(0.3096*(1-K(2)))+(1-x)^2*0.5442)/((2^0.5)*R*T)
failed with the following error:

Error using ==> inlineeval
Error in inline expression ==> (x^2*0.0751+0.6192*x*(1-x)*(1-K(2))+(1-x)^2*0.5442)+(x^2*27.5511+2*x*(1-x)*(2.3716e+004)^0.5*(1-K(1))+(1-x)^2*860.8071)*(x^2*0.0751+2*x*(1-x)*(0.3096*(1-K(2)))+(1-x)^2*0.5442)/((2^0.5)*R*T)
??? Error using ==> mpower
Matrix must be square.

Error in ==> lsqcurvefit at 149
[x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
回复
分享到:

使用道具 举报

发表于 2006-12-1 10:43 | 显示全部楼层
原帖由 hongyie 于  10:33 AM 发表
>> x=
y=
fun=inline('(x^2*0.0751+0.6192*x*(1-x)*(1-K(2))+(1-x)^2*0.5442)+(x^2*27.5511+2*x*(1-x)*(2.3716e+004)^0.5*(1-K(1))+(1-x)^2*860.8071)*(x^2*0.0751+2*x*(1-x)*(0.3096*(1-K(2)))+(1-x)^2* ...



请看matlab基础书关于“点乘和乘的区别”
 楼主| 发表于 2006-12-1 11:09 | 显示全部楼层
已解决
非常感谢2楼!!!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-9-24 23:30 , Processed in 0.066074 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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