If you have:
A = rand(3); b = rand(3,1);
then the system solution can simply be calculated as:
x = A\b
Or, if you already have an LU decomposition A, then:
[L,U] = lu(A); xx = U\(L\b)
mldivide function is smart enough to detect that the matrix is โโtriangular, and chose the algorithm accordingly (forward / reverse replacement)
source share