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

조회 수: 5 (최근 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
Marcelin Dierickx
Marcelin Dierickx 2018년 12월 29일
Not showing me errors anymore indeed, gotta calculate for some hours now !
Thank you :-)

댓글을 달려면 로그인하십시오.

추가 답변 (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.
Marcelin Dierickx
Marcelin Dierickx 2018년 12월 29일
Yeah that was it thank you :-)

댓글을 달려면 로그인하십시오.

카테고리

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