Question: can anyone modify this gauss elim code into LU gauss elimination function [ x ] = GaussElim(a,b) %this function solves a sytem of linear equations

can anyone modify this gauss elim code into LU gauss elimination

function [ x ] = GaussElim(a,b)

%this function solves a sytem of linear equations [a][x]=[b] using the

%Gaussian elimination method

% Input variables:

% a The matrix of coefficients

% b The right-hand side column vector of constants

% Output variable:

% x A column vector with the solution

ab = [a,b];

[R,C] = size(ab);

for j = 1:R-1

for i = j + 1:R

ab(i,j:C) = ab(i,j:C) - ab(i,j)/ab(j,j)*ab(j,j:C);

end

end

x=zeros(R,1);

x(R) = ab(R,C)/ab(R,R);

for i = R - 1:-1:1

x(i) = (ab(i,C) - ab(i,i+1:R)*x(i+1:R))/ab(i,i);

end

please use comment and write clearly

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!