Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the backslash command with more than 2 variables?

I have the following homework question:

Use MATLAB’s 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 THE ANSWER.

I am simply looking for an explanation on how this backslash command works with more than two variables. All the examples I'm finding using Google just show two variables to solve Ax=B. I cannot figure out how to apply this to my problem with 4 variables.

Can someone show me how to expand this to apply to a 3 or more variable set of equations?

like image 479
xcdemon05 Avatar asked Jan 25 '26 18:01

xcdemon05


1 Answers

The fact that you have 4 variables does not change the way in which Matlab sees your sets of equations.

The general form Ax = B, where you want to solve x, can take up as many variables as you want since the unknowns are in the array x. Maybe I'm not clear, so here 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 is 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 the set of equations, regardless of their numbers. Hope it's a bit clearer and I did not give you the answer :P.

like image 126
Benoit_11 Avatar answered Jan 28 '26 17:01

Benoit_11



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!