Pivoting Gaussian Elimination Coding
Mostra commenti meno recenti
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 Commento
Aveek Podder
il 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).
Risposte (0)
Categorie
Scopri di più su Numerical Integration and Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!