Gaussian elimination with partial pivoting

Hi everyone, i am confused as to how to convert my basic pivoting to partial pivoting in my matlab code, could you kindly help me out.
My code is below:
function x=gaussellpp(A,b)
AugMat=[A,b];
[m,n]=size(AugMat);% number of rows and columns
for j=1:m-1
for z=2:m % pivoting
if AugMat(j,j)==0
t=AugMat(j,:);AugMat(j,:)=AugMat(z,:);
AugMat(z,:)=t;
end
end
for i=j+1:m % convert elements below the major diagonal to 0
AugMat(i,:)=AugMat(i,:)-AugMat(j,:)*(AugMat(i,j)/AugMat(j,j));
end
end
x=zeros(1,m); % backwards substituition
for s=m:-1:1
c=0;
for k=2:m
c=c+AugMat(s,k)*x(k);
end
x(s)=(AugMat(s,n)-c)/AugMat(s,s);
end
AugMat;
x';
end
Thank you

Answers (0)

Categories

Products

Release

R2019b

Asked:

on 5 Dec 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!