| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 783 人关注过本帖
标题:请教个问题
只看楼主 加入收藏
mqwe818
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-6-1
收藏
 问题点数:0 回复次数:1 
请教个问题

clear all
clc
x1 = [100 94.83 85.09 77.33 63.28 53.17 45.03 32.8 19.62 18.17 3.7 2.44 1.18 0]
x2 = 100 - x1
T = [414.75 408.35 406.95 404.24 385.15 376.71 368.45 345.38 338.38 333.18 328.58 326.65 320.65 318.15]
a1 = [4.02291,1221.781,-45.739];
a2 = [4.19518,1649.55,-59.836];
Ps1 = Psat(T,a1)
Ps2 = Psat(T,a2)

% 非线性最小二乘法(非线性数据拟合)
lb = [0 0];
ub = [+inf +inf];
beta0 = [1 1];
[beta,resnorm,residual,exitflag,output,lambda,jacobian] = ...
lsqnonlin(@ObjFunc,beta0,lb,ub,[],x1,x2,Ps1,Ps2)
ci = nlparci(beta,residual,jacobian)
[P1,P2,Pcal] = PressureCal(beta,x1,x2,Ps1,Ps2);
y1 = P1./Pcal;

% ------------------------------------------------------------------
function f = ObjFunc(A,x1,x2,Ps1,Ps2)
[P1,P2,Pcal] = PressureCal(A,x1,x2,Ps1,Ps2);
f = Pcal - 300;

% ------------------------------------------------------------------
function [P1,P2,Pcal] = PressureCal(A,x1,x2,Ps1,Ps2)
gamma1 = exp(A(1)*x2./x1+A(1)*x2)./(40*(x1+A(1)*x2)*exp(A(2)*x2./A(2)*x1+x2));
gamma2 = exp(A(2)*x1./x2+A(2)*x1)./(40*(x2+A(2)*x1)*exp(A(1)*x1./A(1)*x2+x1));
P1 = x1.*gamma1.*Ps1;
P2 = x2.*gamma2.*Ps2;
Pcal = P1 + P2;

% ------------------------------------------------------------------
function Ps = Psat(T,a)
% Calculation of the saturation pressure of component i
% T = temperature,℃
% a (vector) = Antoine constants of component i
logPs = a(1)-a(2)./(T+a(3))
Ps = exp(log(10)*logPs)
程序错误如下:
??? Error using ==> f:/matlab/toolbox/optim/private/lsqncommon
User supplied function failed with the following error:

Error using ==> *
Inner matrix dimensions must agree.

Error in ==> F:\matlab\toolbox\optim\lsqnonlin.m
On line 121 ==> [x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...

Error in ==> F:\tools\1548\1548\Examples\Chapter 7\VLE.m
On line 32 ==> [beta,resnorm,residual,exitflag,output,lambda,jacobian] = ...
望高手赐教,小弟在线等
谢谢了!!!!!!!!!!!!!!!!!!

2006-06-01 14:31
Genial
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:175
专家分:0
注 册:2006-3-31
收藏
得分:0 
自己把警告看清楚,然后断点调试,是不是也是该用点乘的?
2006-06-01 14:46
快速回复:请教个问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018281 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved