clear
clc
function x = partialpivot(A,b)
n = length(b);
Ab = [A b];
for i = 1:n-1
maxval = abs(Ab(i,i));
maxrow = i;
for k = i+1:n
if abs(Ab(k,i)) > maxval
maxval = abs(Ab(k,i));
maxrow = k;
end
end
temp = Ab(i,:);
Ab(i,:) = Ab(maxrow,:);
Ab(maxrow,:) = temp;
for j = i+1:n
m = Ab(j,i)/Ab(i,i);
Ab(j,i:n+1) = Ab(j,i:n+1) - m*Ab(i,i:n+1);
end
end
x = zeros(n,1);
x(n) = Ab(n,n+1)/Ab(n,n);
for i = n-1:-1:1
sum_ax = 0;
for j = i+1:n
sum_ax = sum_ax + Ab(i,j)*x(j);
end
x(i) = (Ab(i,n+1)-sum_ax)/Ab(i,i);
end
end
Cite As
Pranavi (2026). partial pivoting (https://www.mathworks.com/matlabcentral/fileexchange/183407-partial-pivoting), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2025b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
