• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Apr 5th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1.
2. // O METODO D ESCALONAMENTO NÃO FUNCIONA DE MANEIRA OTIMA, É SIMPLISTICO !
3. function mPronta = escalonamento(m, L)
4.     for(i = 1:L)
5.         for(j = (i+1):L)
6.             if(m(i,i) ~= 0)
7.                 c = ( m(j,i)/m(i,i) ) * (-1);
8.                 m(j,:) = m(j,:) + m(i,:) * c;
9.             end
10.         end;
11.     end;
12.     mPronta = m;
13. endfunction
14.
15. function s = gauss(m, L, C)
16.     s = zeros(L,1);
17.     for(i = L:-1:1)
18.         s(i) = m(i,C);
19.         for(j = i+1:L)
20.             s(i) = s(i) - m(i,j) * s(j);
21.         end
22.         s(i)= s(i)/m(i,i);
23.     end
24. endfunction
25.
26. // leitura
27. m = [ 1 -3 2; -2 8 -1; 4 -6 5];
28. r = [ 11; -15; 29];
29. m(:, \$+1) = r;
30.
31. // escalonando
32. tam = size(m);
33. m = escalonamento(m,tam(1,1)); // passando o numero de linhas em tam(1,1)
34. disp(m);
35.
36.
37. // gauss
38. coef = gauss(m, tam(1,1), tam(1,2) );
39. // valores de X0 ate Xn-1
40. disp(coef);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top