I'm trying to do the dot product between two 3x3x3x3x3 matrices in Matlab. Following the Matlab documentation about the dot function for multidimensional arrays, I expect the result of this:
A=2*ones(3,3,3,3,3);
B=3*ones(3,3,3,3,3);
dot(A,B,1);
to be a 4D matrix, because the dot product between each column of A and each column of B reduces the resulting matrix by a dimension. Instead, this is the output in the workspace:
I can't understand this, why does it happen?
Thank you in advance.
The answer is a 5-D double because you've collapsed the first dimension. So the first dimension is now of size 1
, and the 2nd-5th dimensions are of size 3
as expected.
You can see this by using size
A = 2 * ones(3,3,3,3,3);
B = 3 * ones(3,3,3,3,3);
C = dot(A,B,1);
size( C ); % = [1 3 3 3 3]