matlab sym 在优化问题中的应用

function hhh
%初值(0.000016 0.000002 0.0125 11252 359 0.9 0.595 0.593 0.937 0.003 2.2125 300)
DDR=1.6;
TS=333;
ms=0.01454;
us=1069.6;
Ps=99763;
As=0.000015588;
A0=DDR^2*As;
MS=0.00018;
x2s=0.99965;
Cvs=(1-0.810031)*1.6+0.810031*2.16;
eq1=sym('MS-MV');
eq2=sym('x2s*MS-x20*M0');
eq6=sym('1/P20');
eq12=sym('0.5*TS*(ms*Cvs+m0*Cv0)+ms*0.5*us^2-m0*0.5*u0^2+(Ps*As*us-P0*A0*u0)-mv*(719.7+1.28*40))/(0.5*(ms*Cvs+m0*Cv0)-mv*2.16)');
[M0,MV,x20,T0]=solve(eq1,eq2,eq6,eq12,'M0,MV,x20,T0');
M0=subs(M0),MV=subs(MV),x20=subs(x20),T0=subs(T0)

fsolve(@myfuns,x0)
function eqs=myfuns(x)
M0=x(1);
MV=x(2);
m0=x(3);
P0=x(4);
u0=x(5);
x20=x(6);
Psat=x(7);
P20=x(8);
V2=x(9);
V1=x(10);
Cv0=x(11);
T0=x(12);
eq1=MS-MV;
eq2=x2s*MS-x20*M0;
eq3=M0*((1-x20)*65175+x20*58.1);
eq4=m0*u0/A0*10;
eq5=m0/A0/0.876;
eq6=1/P20;
eq7=(EXP(16.6513-2940.49/(T0-35.93)))/760;
eq8=Psat*V2*EXP(V1*(1-73.53/31147-V1*V2*0.11));
eq9=x20*1.31/(x20*1.31+(1-x20)*0.79);
eq10=1-V2;
eq11=(1-V2)*1.6+V2*2.16;
eq12=(0.5*TS*(ms*Cvs+m0*Cv0)+ms*0.5*us^2-m0*0.5*u0^2+(Ps*As*us-P0*A0*u0)-mv*(719.7+1.28*40))/(0.5*(ms*Cvs+m0*Cv0)-mv*2.16);
eqs=[eq1;eq2;eq3;eq4;eq5;eq6;eq7;eq8;eq9;eq10;eq11;eq12];
fsolve(@myfuns,[0.000016 0.000002 0.0125 11252 359 0.9 0.595 0.593 0.937 0.003 2.2125 300])
Error using feval
Undefined function 'myfuns' for input arguments of type 'double'.

Error in fsolve (line 243)
            fuser = feval(funfcn{3},x,varargin{:});

Caused by:
    Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
上一篇:读懂M0,M1,M2


下一篇:(五)Sharding-JDBC读写分离