Created
March 17, 2015 18:06
-
-
Save senhorinha/8d494456446e60282392 to your computer and use it in GitHub Desktop.
Escalonamento de Gauss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 3 % número de equações | |
A = [1 2 3 4; -5 7 8 1; -7 8 9 13;] | |
% processo de triangularização | |
for k = 1 : n - 1 % passo do escalonamento | |
for i = k + 1 : n % linha a ser escalonada | |
aux = A(i,k)/A(k,k) | |
% para j = k o valor será nulo sempre | |
A(i,k) = 0; | |
for j = k + 1 : n + 1 | |
A(i,j) = A(i,j) - aux*A(k,j) % Li = Li - Lk | |
end | |
end | |
end | |
% processo de retosubstituição | |
x(n) = A(n, n+1) / A(n,n) | |
for i = n -1: -1 : 1 | |
soma = 0; | |
for j = i + 1 : n | |
soma = soma + A(i,j) * x(j); | |
x(i) = (A(i, n+1) - soma)/A(i,i) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment