How do I use the backslash command with more than two variables?
I have the following homework question:
Use MATLABs Backslash Command to Set Up and Solve the System
5a - 2b + d = 7
-a + 6b + 2c - 9d = 12
3c - 4d = 3
a + b + c + d = 0
PLEASE DO NOT GIVE ME ANSWER.
I'm just looking for an explanation of how this backslash command works with more than two variables. All the examples I google I find just show two variables for the Ax = B solution. I can't figure out how to apply this to my 4 variable problem.
Can anyone show me how to extend it to apply to 3 or more variable sets of equations?
source to share
The fact that you have 4 variables does not change the way Matlab sees your sets of equations.
The general form Ax = B
where you want to solve x can take as many variables as you like, since the unknowns are in the x array. Maybe I don't understand, so this is how it translates to your problem.
A is a matrix of coefficients located before a, b, c and d. Since you have 4 equations, A is 4x4:
A =
5 2 0 1
-1 6 2 -9
0 0 3 -4
1 1 1 1
and B the following:
B = 7 12 3 0
while x looks like this: (sorry for the formatting):
x = a b c d
So, if you had 2 equations / variables, A would be 2x2, and you would still use the same nomenclature to solve a set of equations, no matter how many. Hope this is a little clearer and I didn't give you an answer: P.
source to share