Sym: The second argument must be a vector of symbolic variables

22 次查看(过去 30 天)
This code:
R = 9 ; T = 300 ; g = 10 ;
syms h p Mm q m v b a f
F = (sqrt((h*(g*(q*(a+v)-m+((m-q*v)/(R*T/(p/q+g*h)-Mm)+b)*(R*T*q/2*(1/p+1/(p+q*g*h))-Mm))-2*f))^2+4*(R*T*((m-q*v)/(R*T/(p/q+g*h)-Mm)+b)*log(R*T*((m-q*v)/(R*T/(p/q+g*h)-Mm)+b)/(p*((Mm*((m-q*v)/(R*T/(p/q+g*h)-Mm)+b)+m)/q-v-a))))^2)-h*(g*(q*(a+v)-m+((m-q*v)/(R*T/(p/q+g*h)-Mm)+b)*(R*T*q/2*(1/p+1/(p+q*g*h))-Mm))-2*f))/(2*R*T*((m-q*v)/(R*T/(p/q+g*h)-Mm)+b)*log(R*T*((m-q*v)/(R*T/(p/q+g*h)-Mm)+b)/(p*((Mm*((m-q*v)/(R*T/(p/q+g*h)-Mm)+b)+m)/q-v-a)))) ;
dF_h = diff(F,h);
dF_p = diff(F,p);
dF_Mm = diff(F,Mm);
dF_q = diff(F,q);
dF_m = diff(F,m);
dF_v = diff(F,v);
dF_b = diff(F,b);
dF_a = diff(F,a);
dF_f = diff(F,f);
[Sh,Sp,SMm,Sq,Sm,Sv,Sb,Sa,Sf] = vpasolve([dF_h==0,dF_p==0,dF_Mm==0,dF_q==0,dF_m==0,dF_v==0,dF_b==0,dF_a==0,dF_f==0],[h,p,Mm,q,m,v,b,a,f],[0 Inf;30000 Inf;2 300;p/(R*T/Mm-g*h) 10000;0 Inf;0 m/q;0 Inf;0 Inf;0 Inf],'Random',true);
Gives me error:
Error using
sym.getEqnsVars>checkVariables (line 92)
The second argument must be a
vector of symbolic variables.
Error in sym.getEqnsVars (line 54)
checkVariables(vars);
Error in sym/vpasolve (line 132)
[eqns,vars] =
sym.getEqnsVars(varargin{1:N});
Error in Rendement (line 17)
[Sh,Sp,SMm,Sq,Sm,Sv,Sb,Sa,Sf] = vpasolve([dF_h==0;dF_p==0;dF_Mm==0;dF_q==0;dF_m==0;dF_v==0;dF_b==0;dF_a==0;dF_f==0],[h;p;Mm;q;m;v;b;a;f],[0 Inf;30000 Inf;2 300;p/(R*T/Mm-g*h) 10000;0 Inf;0 m/q;0 Inf;0 Inf;0 Inf],'Random',true);
And I don't get why.
The equation is long, no real need to read them.
Thank you for answering.

采纳的回答

Walter Roberson
Walter Roberson 2018-12-28
You cannot use symbolic variables in the bounds.
You can add constraints as expressions to be solved for.

更多回答(1 个)

madhan ravi
madhan ravi 2018-12-28
编辑:madhan ravi 2018-12-28
doc vpasolve % read the right usage of it
[Sh,Sp,SMm,Sq,Sm,Sv,Sb,Sa,Sf] = vpasolve([dF_h==0,dF_p==0,dF_Mm==0,dF_q==0,dF_m==0,dF_v==0,dF_b==0,dF_a==0,dF_f==0],[h,p,Mm,q,m,v,b,a,f]); % only this the others after f]... I don't know why you have added
  3 个评论
madhan ravi
madhan ravi 2018-12-29
编辑:madhan ravi 2018-12-29
well you are right buddy but then it’s mentioned no where that the init_guess should be symbolic I can see in two places p/(...) and m/q are symbolic variables which is leading to error.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by