Gaussian elimination with partial pivoting

조회 수: 13 (최근 30일)
ahmed saheed
ahmed saheed 2020년 12월 5일
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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by