www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/DecomposeASquareMatreixExample.m

    %% Decompose a Square Matrix
%%
% *Note*: This example runs only in R2016b or later. If you are using an
% earlier release, replace each call to the function with the equivalent
% |step| syntax. For example, myObject(x) becomes step(myObject,x).

%%
% Decompose a square matrix into the lower and upper components.
hlu = dsp.LUFactor;
x = rand(4)
[LU, P] = hlu(x);
L = tril(LU,-1)+diag(ones(size(LU,1),1));
U = triu(LU);
y = L*U
%%
% Check back whether |y| equals the permuted |x|
xp = x(P,:)