The purpose is to pre-allocate the matrix memory. Here, Aij needs to be initialized as a matrix of ncomp rows and columns, so use zeros to set all its elements to 0, and then set each element to the required value in the next row of loop calculation. Of course, you can also use ones () to set it all to 1.
The size () function is used to get the number of rows and columns of the matrix, ncomp = size(comp,1); Where represents the number of rows to obtain comp, similarly ncomp = size(comp, 2); Gets the number of columns.
2. Amix = comp' * Aij * comp Why is it transposed here?
This is not a matter of procedure. Transposition depends on your math problem.