110084888-metodo-de-gauss-y-de-gauss-jordan.pdf

  • Uploaded by: Daniel Hernández
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 110084888-metodo-de-gauss-y-de-gauss-jordan.pdf as PDF for free.

More details

  • Words: 216
  • Pages: 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Método de Gauss (Triangularización) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Versión 1.00 Mayo 1999 % Desarrollado por Marelys, MUJICA clear all clc

disp(' disp('

Método de Gauss') Resuelve el sistema Ax=b')

a=input('Introduzca la matriz A: '); b=input('Introduzca la matriz b (en vectores fila): '); [Ma,Na]=size(a); [Mb,Nb]=size(b); a=[a, b']; [M,N]=size(a); %tamano de la matriz aumentada PP=input('Desea usar el metodo del pivote maximo Si(1) No(2) if PP == 1 for j=2:M piv=j-1; pivm=max(a(:,piv)); %pivote maximo for k=piv:M if a(k,piv) == pivm tempo=a(piv,:); a(piv,:)=a(k,:); a(k,:)=tempo; end end for i=j:M a(i,:)=a(i,:)-a(i,piv)*a(piv,:)/a(piv,piv); end end end if PP == 2 for j=2:M piv=j-1; for i=j:M a(i,:)=a(i,:)-a(i,piv)*a(piv,:)/a(piv,piv); end end end a; %retrosustitución cont=0; for p=Na+1:N x(M)=a(M,p)/a(M,M); cont=cont+1; for m = M-1: -1: 1 S=0; for n = M: -1: m+1 S=S+a(m,n)*x(n); end

');

x(m)=(a(m,p)-S)/a(m,m); end fprintf('Solucion%3.0f\n', cont) x end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Método de Gauss Jordan (Diagonalización) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Versión 1.00 Mayo 1999 % Desarrollado por Marelys, MUJICA clear all clc

disp(' disp('

Método de Gauss Jordan') Resuelve el sistema Ax=b')

a=input('Introduzca la matriz A: '); b=input('Introduzca la matriz b: '); [Ma,Na]=size(a); [Mb,Nb]=size(b); a=[a, b']; [M,N]=size(a); %tamaño de la matriz aumentada for j=2:M+1 piv=j-1; pivm=max(a(:,piv)); %pivote máximo for k=piv:M if a(k,piv) == pivm tempo=a(piv,:); a(piv,:)=a(k,:); a(k,:)=tempo; end end for i=j:M a(i,:)=a(i,:)-a(i,piv)*a(piv,:)/a(piv,piv); end for l=1:piv-1 a(l,:)=a(l,:)-a(l,piv)*a(piv,:)/a(piv,piv); end end a %resultado for h=1:M x(h)=a(h,N)/a(h,h); end x

More Documents from "Daniel Hernández"