In: Computer Science
x+ 2y−3z=−18
2x+ 6y−10z=−34
−x−4y+ (a+ 3)z=a2
You need to use MATLAB for this part: Open a MATLAB session, create a script and save it under the name:yourfamilyname_yourfirstname_A_1.Do the following work in your script and save and publish it as a PDF, as shown in MATLAB Demo Part 2. You will need to include the published PDF of All the MATLAB work in your electronic submission in Canvas.
(a) For the system given in Question 1, let a= 5327. Create the corresponding augmented matrix in MATLAB.
(b) (2 Find the reduced row echelon form of the augmented matrix in MATLAB and read out the solutions from it.
(c) Create the coefficient matrix (i.e. Do Not include the right hand side constants) and call it A.
(d)Create a column vector of the right hand side and call it b.
(e) Use a the “ matrix left division” in MATLAB to solve the resulted linear system.(Hint: The backslash command,\, in MATLAB is what you need to use; either get help on\or get help on\ml divide).
Please provide a full solution for the question.
please also post a decent screen shot of the coding on matlab.
Code for the above question is given below
a=5327
A=[1 2 -3; 2 6 -10; -1 -4 a+3] %defining the matrix A.(part c)
b=[18 34 a^2]' % defining the solution matrix; I interpreted a2 as a2. ' in the end makes b a column vector. (part d)
Aaug=[A b] % part a, creating augmented matrix.
C = rref(Aaug) % creating a row echelon form, though solution is clearly visible still I have printed it using the command in next line
x = C(:,end) %from the matrix x=-5311, y=10661, z=5331
sol= A\b % A\b to get the solution.
Output
a =
5327
A =
1 2 -3
2 6 -10
-1 -4 5330
b =
18
34
28376929
Aaug =
1 2 -3 18
2 6 -10 34
-1 -4 5330 28376929
C =
1 0 0 -5311
0 1 0 10661
0 0 1 5331
x =
-5311
10661
5331
sol =
1.0e+04 *
-0.5311
1.0661
0.5331
We can see that rref and A\b gives same solution for x, y, z. Here 1.0e+04 is multiplied with all the 3 numbers and the sol is same as x.
Screen shots of the code with the o/ps are attached.