Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is my exercise 1 code: function x = gaussElimination(A, b) A = [2 1 -1 2; 4 5 -3 6; -2 5 -2 6;

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How does a cash budget differ from a pro-forma income statement?

Answered: 1 week ago