|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
<P>用matlab解非线性方程组出错了,出错信息如下:<BR>?? In an assignment A(I) = B, the number of elements in B and<BR> I must be the same.<BR><BR>Error in ==> thermal>NonlinEqs at 24<BR>f(4)=x(3).^2.*x(4).^2-K1.*x(1).*x(2)./(P./xtotal).^2;<BR><BR>Error in ==> fsolve at 180<BR> fuser = feval(funfcn{3},x,varargin{:});<BR><BR>Error in ==> thermal at 14<BR>x1 =fsolve(@NonlinEqs,x0,[],K1,K2,K3,n10,n20)<BR><BR><BR>程序如下<BR>function xFsolve<BR>% xFsolve.m<BR>% 求解热力学平衡计算</P>
<P>clear all<BR>clc</P>
<P>n10=0.2;n20=1-n10;<BR>T=500:100:1500; %体系温度,K<BR>K1=exp(7.9305.*log(T)-5.6347e-03.*T+5.8622e-07.*T.^2-2.7848e+04./T-19.03390284);<BR>K2=exp(0.248617.*log(T)-1.4693e-03.*T+2.28e-07.*T.^2-4.1539e+04./T+4.213066);<BR>K3=exp(6.833053.*log(T)-3.7606e-03.*T+3.48e-07.*T.^2-7.276675e+03./T-33.8969);<BR>x0 = [n10 n20 0 0 0 0]';<BR>x1 =fsolve(@NonlinEqs,x0,[],K1,K2,K3,n10,n20)</P>
<P><BR>% ------------------------------------------------------------------<BR>function f = NonlinEqs(x,K1,K2,K3,n10,n20)<BR>P=101325;<BR>xtotal=x(1)+x(2)+x(3)+x(4)+x(5)+x(6);<BR>f(1) = x(1)+x(2)+x(3)+x(6)-1;<BR>f(2) = 2*x(1)+x(4)+x(5)-2*n10;<BR>f(3)=2.*x(2)+x(3)+x(5)-2*n20;<BR>f(4)=x(3).^2.*x(4).^2-K1.*x(1).*x(2)./(P./xtotal).^2;<BR>f(5)=x(3).*x(5)-K2.*x(2).*x(4);<BR>f(6)=x(6).*x(4).^2-K3.*x(1);<BR><BR><BR></P> |
|