3

I have .mat file that contains a binary (0,1) matrix with size 100*100*100. I have used this syntax to import it in mathematica

binarymap=Import["matlab.mat","Data"]
Dimensions@binarymap(*Why the dimensions is not 100*100*100?*)
{1,100,100,100}

binarymap[[1,1,1,1]] == False (*Why false?*)

When I load it in Matlab, it works correctly. What is the problem?

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
BetterEnglish
  • 2,026
  • 13
  • 19

1 Answers1

4

First of all I want to make it clear that Mathematica does import this file correctly.

MAT files can contain multiple variables. When importing a MAT file, Mathematica always returns a list of the values of these variables. It appears that your MAT file contains a 3D array. Thus Mathematica returns a list with a single element, that element being a 3D array.

If instead of the "Data" element you import the "LabeledData" or "Labels" elements, you will be able to see the variable names as well.

It also appears that your file contains an array of logical type (i.e. MATLAB's Boolean type). Importing it gives an array of True and False values. MATLAB displays "true" as 1, but don't be mistaken: this is not a number, it is a truth value. See here: http://www.mathworks.com/help/matlab/ref/logical.html

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263