Write a MATLAB code to find the L and U decompostions of a matrix

6 views (last 30 days)
I cannot use the MATLAB built in functions to find the Lower Triangle and Upper Triangle decompositions of a matrix that would solve this easily. I have to write my own. This is what I have so far but now I don't know what to do next.
function [ L1 U1 ] = LUdecomp( A )
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
AA = A;
n = n1;
L = zeros(n1,n2);
U = zeros(n1,n2);
m = 1;
while n~=0;
alpha = AA(1,1);
v = AA(2:n,1);
w = AA(1,2:n);
end

Answers (1)

Udoi
Udoi on 22 Jun 2022
To decompose a matrix into lower and upper and lower triangular matrices,we can use the following syntax:
[LU,P] = step(lu,A)
[LU,P,S] = step(lu,A)
[LU,P] = step(lu,A) decomposes the matrix A into lower and upper triangular matrices. The output LU is a composite matrix with lower triangle elements from L and upper triangle elements from U . The permutation vector P is the second output.
[LU,P,S] = step(lu,A) returns an additional output S indicating if the input is singular when the ExceptionOutputPort property is set to true.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!