Using SOLVE command with syms

1 visualización (últimos 30 días)
GAGANDEEP KAUR
GAGANDEEP KAUR el 2 de Nov. de 2020
I also need to determine some variables using syms with solve command but find some issue with syms itself.
Code is like this:
for i=1:9
syms a b c d e ;
%calculating mole fractions of ionic species
x1=[0.5096 0.5092 0.5087 0.4852 0.4847 0.4834 0.4804 0.4805 0.4803];
x2=[0.0963 0.0964 0.0965 0.1163 0.1161 0.1158 0.1275 0.1266 0.1253];
x3=[0.3941 0.3944 0.3948 0.3985 0.3992 0.4008 0.3921 0.3929 0.3943];
T=[394.15 399.15 404.15 375.15 390.15 405.15 374.15 392.15 406.15];
%Equilibrium constant for reaction 1 (Solvation reaction)
K1=exp((-8.549)+(6692/T(i)));
%Equilibrium constant for reaction 2(Ionization of water)
K2=10^(-14);
%Equilibrium constant for reaction 3(Dissociation of HI)
K3=exp((16.93565)+((1250)/T(i))+(-2.575*log(T(i))));
%Equilibrium constant for reaction 4(Polyiodide formation a)
K4=exp((-936.28)+((40216.27)/T(i))+(151.983*(log(T(i))))+(-0.1675*(T(i))));
%Equilibrium constant for reaction 5(Polyiodide formation b)
K5=exp((1044.78)+(-45171.42/T(i))+(-165.20*log(T(i)))+(0.1511*(T(i))));
eqns=[((d*(c-e))/((x1(i)-a-b-c-d)^5)*(x2(i)-d-b-c))==K1,((a+b+c)*a)/((x1(i)-a-b-c-d)^2)==K2,(((a+b+c)*(d+b))/((x1(i)-a-b-c-d)*(x2(i)-d-b-c-e)))==K3,(((a+b+c)*(c-e))/((x1(i)-a-b-c-d)^4*(x2(i)-d-b-c-e)))==K4,(((e)*(x1(i)-a-b-c-d)^3)/((c-e)*(x3(i)-e)))==K5];
S=solve(eqns,a, b, c, d, e)
S.a(S.a<0)=[];
S.b(S.b<0)=[];
S.c(S.c<0)=[];
S.d(S.d<0)=[];
S.e(S.e<0)=[];
S.a=double(S.a);
S.b=double(S.b);
S.c=double(S.c);
S.d=double(S.d);
S.e=double(S.e);
end
A positive response is awaited

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by