I have a 3D array like this:
A = rand(2,2,2);
I want to multiply its sub-arrays like this:
But I can't because they are not the same size. This jars with my intuition from linear algebra, since if I restrict one dimension of a 3-D array, I should get a 2-D array (in this case A(1,:,:) and A(:,1,:) should both be 2×2 matrices, and therefore they should commute). It seems MATLAB does not treat all dimensions equal, and only A(:,:,1) is a 2-D array and a 2×2 matrix:
What is the logic of how MATLAB deals with this? Any suggestions for doing operations of this kind?