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)

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!