TAREA 8 PEM - Solucion Pivotaje Ficticio
Click here to load reader
-
Upload
augusto-rodriguez -
Category
Documents
-
view
16 -
download
0
Transcript of TAREA 8 PEM - Solucion Pivotaje Ficticio
UNIVERSIDAD DE GUANAJUATO – PROGRAMACIÓN EN MATLAB TAREA8 – SOLUCIÓN DE SISTEMAS DE ECUACIONES CON PIVOTAJE
JOSÉ AUGUSTO RODRÍGUEZ MARTÍNEZ
Matlab nos puede servir para hacer una función para el método de eliminación que incorpore el
pivotaje ficticio.
El programa queda de la siguiente manera:
function x = gaussp(a,b) n=length(a); p=1:n; for i=1:n-1 [m,r]=max(abs(a(i:n,i))); r=r+i-1; p([i r])=p([r i]); for k=i+1:n l=a(p(k),i)/a(p(i),i); a(p(k),i+1:n)=a(p(k),i+1:n)-l*a(p(i),i+1:n); b(p(k))=b(p(k))-l*b(p(i)); end a(p(i+1:n),i)=0; end x=zeros(n,1); for i=n:-1:1 x(i)=(b(p(i))-a(p(i),i+1:n)*x(i+1:n))/a(p(i),i); end return
Entonces en la pantalla de comando y definimos la matriz A y la matriz B y madnamos llamar a la
función “gaussp”.
>> A=[1 2 3; 4 5 6; 7 8 9]
>> B=[1;2;3]
>> gaussp(A,B)
ans =
-0.3333
0.6667
0