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.
댓글 수: 0
채택된 답변
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
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
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 Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!