# Solving a system of equations without "syms"

53 visualizaciones (últimos 30 días)
Daniel Miller el 11 de Oct. de 2019
Respondida: GAGANDEEP KAUR el 2 de Nov. de 2020
Hello!
I have been given the following system of equations that I should solve:
2x1 + 4x2 + 7x3 = 64
3x1 + x2 + 8x3 = 71
-2x = -4
Now, the problem is that I'm on the MatLab Grader platform and it doesn't seem to have this Symbolic Math Tool (i.e. "syms") in it. It only returns the error "Undefined function 'syms' for input arguments of type 'char'."
My code looks like this:
syms x1 x2 x3
equation1 = 2*x1 + 4*x2 + 7*x3 == 64;
equation2 = 2*x1 + 1*x2 + 8*x3 == 71;
equation3 = -2*x1 == -4;
solutionX = solve([equation1, equation2, equation3], [x1, x2, x3]);
SolutionX1 = solution.x1
SolutionX2 = solution.x2
SolutionX3 = solution.x3
Is there any other method I could use instead of using "syms"?
Thank you in advance!
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

jeewan atwal el 11 de Oct. de 2019
A*x = b;
A = [2 4 7; 2 1 8; -2 0 0];
b = [64;71;-4];
where x = [x1;x2;x3]
solution x can be found using either of two methods as follows:
x = inv(A)*b;
or
x = linsolve(A,b)
##### 4 comentariosMostrar 2 comentarios más antiguosOcultar 2 comentarios más antiguos
jeewan atwal el 11 de Oct. de 2019
If you have any doubt, you are free to ask. Happy to help.
Thankyou Steven Lord for the info.
Daniel Miller el 11 de Oct. de 2019
Alright, thanks for the additional heads-up. Don't know how I would've solved this without your help so big appreciations for it!

Iniciar sesión para comentar.

### Más respuestas (2)

Stephan el 11 de Oct. de 2019
Editada: Stephan el 11 de Oct. de 2019
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Daniel Miller el 11 de Oct. de 2019
Hello and thank you for the advice as well!

Iniciar sesión para comentar.

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
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Comunidades de usuarios

Más respuestas en  Distance Learning Community

### Categorías

Más información sobre Number Theory en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by