Question: MATLAB and partial pivoting! Write a program (either write a new program yourself or modify gauss_elim.m on the course website) to solve the linear system

MATLAB and partial pivoting!

Write a program (either write a new program yourself or modify gauss_elim.m on the course website) to solve the linear system Ax = b by Gaussian elimination and back substitution, without any pivoting. run it as follows: A = [ 3 2 -4 ; -4 5 -1 ; 2 -3 5 ] b = [ -5 ; 3 ; 11 ] x = gauss_elim(A,b) Try also A = [ 3 2 -4 ; 2 -3 5 ; -4 5 -1 ] b = [ -5 ; 11 ; 3 ] x = gauss_elim(A,b) which is the first system, but with the equations are written in a different order (in this case, it is clear from the output that the program does not do interchange the rows of the augmented matrix since pivoting is not used). In the case A = [ 1 2 3 ; 4 5 6 ; 7 8 9 ] b = [ -5 ; 3 ; 11 ] x = gauss_elim(A,b) explain what went wrong (hint: what is det A?). Please submit your code, output, and explanation.

This is the provided code: Please help! I'm not sure where to start

clear;

A = [3 2 -4; -4 5 -1; 2 -3 5];

b = [-5; 3; 11];

%

% inputs: A of size nxn

% b of size nx1

[nrow ncol]=size(A);

if(nrow ~= ncol)

disp('Error: Square coefficient matrix required!!');

return;

end

nb = size(b);

if (nrow ~= nb(1) | nb(2)~=1)

disp('Error: size of b is incompatible!!!');

return;

end

% Gaussian Elimnation

for i = 1:nrow-1

% Fill in the details here

end

% Backwards substitution

x = zeros(nrow,1);

x(nrow) = b(nrow)/A(nrow,nrow);

for i = nrow-1:-1:1

% Fill in the details here

end

x

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!