I want to calculate all possible combinations of adding elements in two NxN matrices, resulting in a NxNxNxN (or N^2xN^2) matrix. My current method uses 4 for-loops, like "sum(i,j,k,l)=A(i,j)-B(k,l), where i,j,k,l=1:N ", but it is quite time-consuming and I'm guessing using matrix multiplication in some way would be more effective, but I can't figure how to do it.
MATLAB: All possible combinations of adding two matrices elementwise
combinationsmatrix operations
Best Answer