Pivoting Gaussian Elimination Coding
Show older comments
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 Comment
Aveek Podder
on 20 Feb 2018
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).
Answers (0)
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!