Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need this in Matlab: Exercise 1 code: function x = gaussElimination(A, b) A = [3 1 -1; 1 -4 2; -2 -1 5]; % Inputting

Need this in Matlab:image text in transcribed

Exercise 1 code:

function x = gaussElimination(A, b)

A = [3 1 -1; 1 -4 2; -2 -1 5]; % Inputting the value of coefficient matrix

b = [3; -1; 2]; % Inputting the value of coefficient matrix

[n, n] = size(A); % Find size of matrix A [n, k] = size(b); % Find size of matrix b x = zeros(n,k); % Initialize x

for i = 1:n-1 for k = i+1:n m = -A(k,i)/A(i,i); % multiplier A(k,:) = A(k,:) + m*A(i,:); b(k,:) = b(k,:) + m*b(i,:); end end

C = [A b] % Use back substitution to find unknowns for j = 1:k 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 end 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= 0 222 223 431 432 433 Note: Please do no just swap rows one with three. Hence solve the linear system Ax = b, where (3 1 -1 A= 1 -4 2 1 -2 -1 5 -- and b=1 Ta (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= 0 222 223 431 432 433 Note: Please do no just swap rows one with three. Hence solve the linear system Ax = b, where (3 1 -1 A= 1 -4 2 1 -2 -1 5 -- and b=1 Ta

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

Generative Artificial Intelligence For Project Management With Aws

Authors: Timothy Krimmel

1st Edition

B0CQV9KWB8, 979-8872627197

More Books

Students also viewed these Databases questions