0% found this document useful (0 votes)
33 views1 page

12 PDF

This function uses Gaussian elimination to solve a system of linear equations represented by the matrix A and vector b. It performs forward elimination to transform A into row echelon form, followed by back substitution to solve for the unknown vector x. The function takes the matrix A, vector b as inputs, performs the Gaussian elimination steps of forward elimination and back substitution, and returns the solution vector x.

Uploaded by

prince
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views1 page

12 PDF

This function uses Gaussian elimination to solve a system of linear equations represented by the matrix A and vector b. It performs forward elimination to transform A into row echelon form, followed by back substitution to solve for the unknown vector x. The function takes the matrix A, vector b as inputs, performs the Gaussian elimination steps of forward elimination and back substitution, and returns the solution vector x.

Uploaded by

prince
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

20/10/19 12:40 PM C:\Users\Prince\Desktop\me6...\Gauss.

m 1 of 1

function x = Gauss(A,b)
n = size(A,2);
%FORWARD ELIMINATION
for k = 1:n-1
for i = k+1:n
factor = A(i,k)/A(k,k);
for j = k+1:n
A(i,k)=0;
A(i,j) = A(i,j) - factor*A(k,j);
end
b(i,1) = b(i,1)- factor*b(k,1);
end
end
%BACK SUBSTITUTION
x(n,1) = b(n,1)/A(n,n);
for j = n-1:-1:1
sum = 0;
for i = n:-1:j+1
sum = sum + A(j,i)*x(i,1);
end
x(j,1) = (b(j,1)- sum)/A(j,j);
end
end

You might also like