LU decomposition

버전 1.0.0 (1.79 KB) 작성자: Umar
By running the provided code with a suitable matrix input, you can obtain the lower and upper triangular matrices resulting from LU decompos
다운로드 수: 5
업데이트 날짜: 2024/8/11

라이선스 보기

%After saving the function, you can test it with a sample
%matrix shown below
%q=[2 1 -1;5 0 2;9 1 0];
%[L,U]=lumine(q);
%disp(L); %display the lower matrix
%disp(U); %display the upper matrix
function [L,U]=lumine(A)
%This function performs LU decomposition on a coefficient
%matrix A,the function takes A as input and returns the
%lower matrix L and uppermatrix U
[m,n]=size(A); %defines m and n
if m~=n %checks if the matrix is square
error('Matrix A must be square');
end
if det(A)==0 % checks if the matrix is singular
error('Matrix cannot be singular');
end
%Initialize L as an identity matrix and
%U as A
L=eye(n);
U=A;
for k=1:n
for i=k+1:n
factor=U(i,k)/U(k,k);
U(i,k:n)-factor*U(k:k,n);
L(i,k)=factor;
end
end
%The diagonal of L should be set to 1(identity property
for i=1:n
L(i,i)=1;
end
end

인용 양식

Umar (2025). LU decomposition (https://www.mathworks.com/matlabcentral/fileexchange/171159-lu-decomposition), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2024a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
도움

도움 받은 파일: Linear Algebra LABS with MATLAB, 2e

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0