I wrote the following Matlab
script:
A=reshape(1:(3*4*5),[3,4,5]);
size(A)
save('A.mat','A');
B=reshape(1:(7*8),[7,8]);
size(B)
save('B.mat','B');
C=reshape(1:(2*3*4*5),[2,3,4,5]);
size(C)
save('C.mat','C');
and it ouput
ans =
3 4 5
ans =
7 8
ans =
2 3 4 5
which shows that indices go increasing.
Then I read these tensors with Mathematica
:
In[20]:= mat = Import["A.mat", "LabeledData"];
In[15]:= Dimensions["A" /. mat]
Out[15]= {5, 3, 4}
In[21]:= mat = Import["B.mat", "LabeledData"];
In[17]:= Dimensions["B" /. mat]
Out[17]= {7, 8}
In[22]:= mat = Import["C.mat", "LabeledData"];
In[23]:= Dimensions["C" /. mat]
Out[23]= {5, 4, 2, 3}
which shows that first two Matlab
indices go to tail in the same order and remaining indices go from the beginning in reverse order.
Is this behaviour by design or by bug? Can I read somewhere about exact rules of index transposing during import?
I see no word about it here.