请达人给看看:
引用完24组数据后调用函数
beta0=[191.2 6392 41770 60920 -2.902 29640 -0.504 -3559 -1.692 2001];
[beta,resnorm]=lsqnonlin(@OptObjFunc,beta0,[],[],[],Y,T,Nin,Nout,yco,yco2,yH2)
function f=OptObjFunc(beta,Y,T,Nin,Nout,yco,yco2,yH2)
global K1 K2 Kco Kco2 KH2 jco jco2 jH2 jm jH2O
然后是一系列计算
K1=beta(1)*exp(-beta(3)/(R*T));
...............
是后我写的function f是
f=[Y(1,: )-(Nin.*yco2-W.*K2.*fco2.*(fH2^3).*(1-B2)./((1+Kco.*fco+Kco2.*fco2+KH2.*fH2)^4))./Nout;
Y(2,: )-W.*(K2.*fco2.*(fH2^3).*(1-B2)./((1+Kco.*fco+Kco2.*fco2+KH2.*fH2)^4)+K1.*fco.*(fH2^2).*(1-B1)./((1+Kco.*fco+Kco2.*fco2+KH2.*fH2)^3))./Nout];
运行时提示的错误是
??? Error using ==> optim\private\lsqncommon
User supplied function ==> OptObjFunc
failed with the following error:
Error using ==> mrdivide
Matrix dimensions must agree.
Error in ==> lsqnonlin at 163
[x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
Error in ==> Kinetics_m at 30
[beta,resnorm]=lsqnonlin(@OptObjFunc,beta0,[],[],[],Y,T,Nin,Nout,yco,yco2,yH2)
我实在是不知道该怎么去改了.....
[
Last edited by identify on 2008-5-29 at 10:38 ]