Your code makes sure that the input A is square. It constructs u and l matrices that are the same size as A. Eventually it does inv(u)*inv(l) which works because inv() of a square matrix is the same size as the matrix and both u and l are the same size. The result of the inv(u)*inv(l) is going to be the same size as the input matrix, A.
But then... it does a matrix multiplication of that calculated result by B. It does that without having verified first that B has the same number of rows that A has. In particular, if the user happened to enter B as a row vector then B will have only one row and the * would likely fail.
Best Answer