File Exchange

image thumbnail

Gaussian Elimination with Pivoting Method

version (4.13 KB) by Cheuk
Function uses Gauss elimination with pivoting to solve a linear system in standard format.


Updated 05 Feb 2014

View License

This function solves a linear system Ax=b using the Gaussian elimination method with pivoting. The algorithm is outlined below:
1) Initialize a permutation vector r = [1, 2,...,n] where r(i) corresponds to row i in A.
2) For k = 1,...,n-1 find the largest (in absolute value) element among a(r(k),k),a(r(k+1),k),...,a(r(n),k).
3) Assume r(j,k) is the largest element. Switch r(j) and r(k).
4) For i=1,...,k-1,k+1,...,n calculates:
zeta = a(r(i),k) / a(r(k),k)
5) For j=k,...,n calculate:
b(r(i)) = b(r(i))-b(r(k))*zeta
6) Steps 1 through 6 has effectively diagonalized A.
7) Each element in the solution vector is:
x(r(i)) = b(i)/a(i,i);


Cite As

Cheuk (2020). Gaussian Elimination with Pivoting Method (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)

Amazing thanks

Yu Wang

Thanks you Cheuk for your kindly sharing. I tried several codes on line but failed. I will do my own and share afterwards.



MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux