Gaussian elimination with partial pivoting
조회 수: 13 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!