## Solving a system of equations without "syms"

### Daniel Miller (view profile)

on 11 Oct 2019
Latest activity Commented on by Daniel Miller

on 11 Oct 2019

### jeewan atwal (view profile)

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"?

### jeewan atwal (view profile)

on 11 Oct 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)

Show 1 older comment
Steven Lord

### Steven Lord (view profile)

on 11 Oct 2019
DON'T use inv. I know that may be how you were told to solve a linear system in school. In theory, that may be fine. In practice, use the backslash operator (\) instead.
jeewan atwal

### jeewan atwal (view profile)

on 11 Oct 2019
If you have any doubt, you are free to ask. Happy to help.
Thankyou Steven Lord for the info.
Daniel Miller

### Daniel Miller (view profile)

on 11 Oct 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!

### Stephan (view profile)

on 11 Oct 2019
Edited by Stephan

on 11 Oct 2019

Daniel Miller

### Daniel Miller (view profile)

on 11 Oct 2019
Hello and thank you for the advice as well!