MATLAB: Save your script to an m-file....The solutions answer has a numerical an
ID: 3842460 • Letter: M
Question
MATLAB: Save your script to an m-file....The solutions answer has a numerical answer, but I need a MATLAB script. (The script I wrote is junk)
9.4 Given the system of equations
2x2 + 5x3 = 1
2x1 + x2 + x3 = 1
3x1 + x2 = 2
(a) Compute the determinant.
(b) Use Cramer’s rule to solve for the x’s.
(c) Use Gauss elimination with partial pivoting to solve for the x’s. As part of the computation, calculate the determinant in order to verify the value computed in (a)
(d) Substitute your results back into the original equations to check your solution.
Explanation / Answer
%Solving first 2 parts as multiple questions are asked
a)
D = [0 2 5;2 1 1;3 1 0];
A = [1;1;2];
X = DA;
disp(X);
%Output
>> dsol
-2.0000
8.0000
-3.0000
b)
D = [0 2 5;2 1 1;3 1 0];
dx = [1 2 5;1 1 1;2 1 0];
dy = [0 1 5;2 1 1;3 2 0];
dz = [0 2 1;2 1 1;3 1 2];
x = det(dx)/d0;
y = det(dy)/d0;
z = det(dz)/d0;
disp(x);
disp(y);
disp(z);
%Output
-2.0000
8.0000
-3.0000
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.