In Matlab Consider this series of linear equations 3x1 4x2 2
In Matlab Consider this series of linear equations: 3x1 +4x2 +2x3 x4 +x5 +7x6 +x7 = 42 2x1 2x2 +3x3 4x4 +5x5 +2x6 +8x7 = 32 x1 +2x2 +3x3 +x4 +2x5 +4x6 +6x7 = 12 5x1 +10x2 +4x3 +3x4 +9x5 2x6 +x7 = 5 3x1 +2x2 2x3 4x4 5x5 6x6 +7x7 = 10 2x1 +9x2 +x3 +3x4 3x5 +5x6 +x7 = 18 x1 2x2 8x3 +4x4 +2x5 +4x6 +5x7 = 17 If you use the matrix inverse technique to solve the above equations, type the matrices(and/or vectors) you need to use, and the command(s) to solve the equations. If you would use the “matrix left division” technique to solve the equations. Type the command(s).
Solution
The given system of equations is :
3x1 + 4x2 + 2x3 x4 + x5 + 7x6 + x7 = 42 [1]
2x1 2x2 + 3x3 4x4 + 5x5 + 2x6 + 8x7 = 32 [2]
x1 + 2x2 + 3x3 + x4 + 2x5 + 4x6 + 6x7 = 12 [3]
5x1 + 10x2 + 4x3 + 3x4 + 9x5 2x6 + x7 = 5 [4]
3x1 + 2x2 2x3 4x4 5x5 6x6 + 7x7 = 10 [5]
2x1 + 9x2 + x3 + 3x4 3x5 + 5x6 + x7 = 18 [6]
x1 2x2 8x3 + 4x4 + 2x5 + 4x6 + 5x7 = 17 [7]
which in MATRIX for AX=b can be written as :
A=
3 4 2 -1 1 7 1
2 -2 3 -4 5 2 8
1 2 3 1 2 4 6
5 10 4 3 9 -2 1
3 2 -2 -4 -5 -6 7
-2 9 1 3 -3 5 1
1 -2 -8 4 2 4 5
and b =
42
32
12
-5
10
18
17
The solution using MATLAB can thus be obtained using the following code:
clear all
clc
%%
A=[3,4,2,-1,1,7,1;2,-2,3,-4,5,2,8;1,2,3,1,2,4,6;5,10,4,3,9,-2,1;...
3,2,-2,-4,-5,-6,7;-2,9,1,3,-3,5,1;1,-2,-8,4,2,4,5];
b=[42;32;12;-5;10;18;17];
X=A\\b
