Pivoting Gaussian Elimination Coding
이전 댓글 표시
I am trying to code a Pivoting Gaussian Elimination code using the algorithm that is posted in the picture. However, on the first iteration under the 2nd for loop(i=...) it is changing A(1,1) to 0 and not A(2,1). Below is the code:
if true
[n,m] = size(A);
[d,p] = sort(A(:,1),'descend');
for k =1:n-1
for i = k + 1:n
z = A(p(i),k) / A(p(k),k);
A(p(i),k) = 0
for j = k + 1:n
A(p(i),j) = A(p(i),j) - z*A(p(k),j);
end
end
end
end
댓글 수: 1
Aveek Podder
2018년 2월 20일
Hi,
p(2) is equals 1 that is the reason why A(p(i),k) = 0 is assigning A(1,1) = 0 instead of A(2,1).
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!