How to do a gauss partial pivot?

4 vues (au cours des 30 derniers jours)
Kevser Cifci
Kevser Cifci le 27 Sep 2021
Commenté : Kevser Cifci le 27 Sep 2021
Hi,
For each row, I want to find the absolute maximum and divide the other elements on the same row with the maximum. I want to do this with each row.
A = [1 2 3; 2 -1 1; 1 1 1]
n = size (A,1);
maximum = 0;
for k = 1 : n
for i = 1 : n
if abs(A(k,i)) >= maximum
maximum = A(k,i);
end
A(k,i) = A(k,i)/maximum;
end
end
A
My algorithm is not giving me the right matrix. Can you help me please?

Réponse acceptée

the cyclist
the cyclist le 27 Sep 2021
A = [1 2 3; 2 -1 1; 1 1 1]
A = 3×3
1 2 3 2 -1 1 1 1 1
A./abs(max(A,[],2))
ans = 3×3
0.3333 0.6667 1.0000 1.0000 -0.5000 0.5000 1.0000 1.0000 1.0000
  1 commentaire
Kevser Cifci
Kevser Cifci le 27 Sep 2021
Thank you !

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by