LU Decomposition Using Crout's Method in MatLab

preview_player
Показать описание
*Turn quality and picture size up on YouTube player for better view*

A quick overview of how to use LU Decomp w/ Crout's Method in MatLab.

function [L, U] = LUdecompCrout(A)
% The function decomposes the matrix A into a lower triangular matrix L
% and an upper triangular matrix U, using Crout's method such that A=LU.
% Input variables:
% A The matrix of coefficients.
% Output variable:
% L Lower triangular matrix.
% U Upper triangular matrix.

[R, C] = size(A);
for i = 1:R
L(i,1) = A(i,1);
U(i,i) = 1;
end
for j = 2:R
U(1,j)= A(1,j)/L(1,1);
end
for i = 2:R
for j = 2:i
L(i,j)=A(i,j)-L(i,1:j-1)*U(1:j-1,j);
end
for j = i+1:R
U(i,j)=(A(i,j)-L(i,1:i-1)*U(1:i-1,j))/L(i,i);
end
end
Рекомендации по теме
Комментарии
Автор

i like your voice! thanks for the inputs.

EjaxPlus
Автор

Thank you
For rectangular matrix A your code fail, and results in 3x3 matrices. You should replace R to C in lines 15 and 22.
Hi

nizanmiz
Автор

can you please explain me the coding thats what i am more interested into because the next step is the gaussian elimination which i have to implement in matlab

sharad
Автор

this function false it's L must have diagonal 1 not U 

amineelk