Question
Here is my exercise 1 code: function x = gaussElimination(A, b) A = [2 1 -1 2; 4 5 -3 6; -2 5 -2 6;
Here is my exercise 1 code:
function x = gaussElimination(A, b)
A = [2 1 -1 2; 4 5 -3 6; -2 5 -2 6; 4 11 -4 8]; b = [5;9;4;2]; [n, n] = size(A); % Find size of matrix A [n, k] = size(b); % Find size of matrix b x = zeros(n,k); % Initialize x
if det(A)~=0 for i = 1:n-1 m = -A(i+1:n,i)/A(i,i); % multipliers A(i+1:n,:) = A(i+1:n,:) + m*A(i,:); b(i+1:n,:) = b(i+1:n,:) + m*b(i,:); end
% Use back substitution to find unknowns x(n,:) = b(n,:)/A(n,n); for i = n-1:-1:1 x(i,:) = (b(i,:) - A(i,i+1:n)*x(i+1:n,:))/A(i,i); end
elseif det(A) == 0 disp("Error: The determinant is 0") end
(b) Modify your code in Exercise 1 of Lab 1 to perform a variation of Gaussian elimination method which returns a matrix in the form To 0 013 A = 1 0 222 223 | 231 232 233 Note: Please do no just swap rows one with three. (b) Modify your code in Exercise 1 of Lab 1 to perform a variation of Gaussian elimination method which returns a matrix in the form To 0 013 A = 1 0 222 223 | 231 232 233 Note: Please do no just swap rows one with three
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started