Docsity
Docsity

Prepara tus exámenes
Prepara tus exámenes

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity


Consigue puntos base para descargar
Consigue puntos base para descargar

Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium


Orientación Universidad
Orientación Universidad

Codigos de matlab para el metodo de eliminacion gausiana, Guías, Proyectos, Investigaciones de Métodos Numéricos

Es un documento donde se muestra como resolver un ejercicio en matlab con eliminacion Gausiana

Tipo: Guías, Proyectos, Investigaciones

2024/2025

Subido el 10/04/2025

luis-granja-1
luis-granja-1 🇨🇴

1 documento

1 / 3

Toggle sidebar

Esta página no es visible en la vista previa

¡No te pierdas las partes importantes!

bg1
Metodo de Doolittle
disp('Metodo de Doolittle');
Metodo de Doolittle
A=input('Ingrese la matriz A en []: ');
b=input('Ingrese el vector b en []: ');
n=size(A);%Tamaño de A
L=eye(n);%Matriz de 1
U=eye(n);%Matriz de 1
cond(A)%verificar si esta bien condicionada la matriz
ans =
4.5228
% halla la fila 1 de U
for j = 1:n
U(1,j) = A(1,j);
end
Warning: Colon operands must be real scalars. This warning will become an error in a future release.
% halla columna 1 de L
for i = 1:n
L(i,1) = A(i,1)/U(1,1);
end
Warning: Colon operands must be real scalars. This warning will become an error in a future release.
for k=2:n % Se hallan las demas filas desde la 2
for j=k:n
Acumulador2 = 0; %Se inicializa el acumulador en cero para el
despeje de U
for p=1:k-1
Acumulador2 = Acumulador2 + L(k,p)*U(p,j); % Acumulador es como
el multiplicador
end
U(k,j) = (A(k,j) - Acumulador2);
end
for i= k:n
Acumulador = 0; %Se inicializa el acumulador en cero para el despeje
de L
for p=1:k-1
Acumulador = Acumulador + L(i,p)*U(p,k);
end
L(i,k) = (A(i,k) - Acumulador)/U(k,k);
end
end
1
pf3

Vista previa parcial del texto

¡Descarga Codigos de matlab para el metodo de eliminacion gausiana y más Guías, Proyectos, Investigaciones en PDF de Métodos Numéricos solo en Docsity!

Metodo de Doolittle

disp('Metodo de Doolittle');

Metodo de Doolittle

A=input('Ingrese la matriz A en []: ');

b=input('Ingrese el vector b en []: ');

n=size(A);%Tamaño de A

L=eye(n);%Matriz de 1

U=eye(n);%Matriz de 1

cond(A)%verificar si esta bien condicionada la matriz

ans =

% halla la fila 1 de U

for j = 1:n

U(1,j) = A(1,j);

end

Warning: Colon operands must be real scalars. This warning will become an error in a future release.

% halla columna 1 de L

for i = 1:n

L(i,1) = A(i,1)/U(1,1);

end

Warning: Colon operands must be real scalars. This warning will become an error in a future release.

for k=2:n % Se hallan las demas filas desde la 2

for j=k:n

Acumulador2 = 0; %Se inicializa el acumulador en cero para el

despeje de U

for p=1:k-

Acumulador2 = Acumulador2 + L(k,p)*U(p,j); % Acumulador es como

el multiplicador

end

U(k,j) = (A(k,j) - Acumulador2);

end

for i= k:n

Acumulador = 0; %Se inicializa el acumulador en cero para el despeje

de L

for p=1:k-

Acumulador = Acumulador + L(i,p)*U(p,k);

end

L(i,k) = (A(i,k) - Acumulador)/U(k,k);

end

end

Warning: Colon operands must be real scalars. This warning will become an error in a future release. Warning: Colon operands must be real scalars. This warning will become an error in a future release. Warning: Colon operands must be real scalars. This warning will become an error in a future release. Warning: Colon operands must be real scalars. This warning will become an error in a future release. Warning: Colon operands must be real scalars. This warning will become an error in a future release. Warning: Colon operands must be real scalars. This warning will become an error in a future release. Warning: Colon operands must be real scalars. This warning will become an error in a future release.

disp('U=')

U=

disp (U)

disp('L=')

L=

disp (L)

disp('L*U=')

L*U=

disp(L*U)

% se inicia la sustitucion progresiva para hallar Z

for i=1:n

Acumulador3 = 0;

for p = 1:i-

Acumulador3=Acumulador3+L(i,p)*Z(p,1);

end

Z(i,1)=(b(i,1)-Acumulador3)/L(i,i);

end

Warning: Colon operands must be real scalars. This warning will become an error in a future release.

disp('Z=');

Z=

disp(Z)