MATLAB Variable Structure
*************************

Variable Information
====================

When a MATLAB variable is read or created, all of the information about the variable (e.g. name, dimensions, etc.) are stored in the MATLAB variable structure type matvar_t.

name
     Nul-terminated string that is the name of the variable. The name may be NULL (e.g. for elements of a cell-array), so the field should be checked prior to use.

rank
     The number of dimensions of the variable. The minimum rank is 2.

dims
     An array of the number of elements in each dimensions of the variable.

class_type
     Indicates the class of the variable (e.g. double-precision, structure, cell, etc.).

data_type
     Indicates the type of the data stored in the data field of the MATLAB variable structure.

isComplex
     is non-zero if the variable is a complex-valued numeric array.

isLogical
     is non-zero of the variable should be interpreted as logical (i.e. zero for false, non-zero for true).

isGlobal
     is non-zero if the variable should be a global variable. In MATLAB a global variable is available in all scopes (e.g. base workspace, function, etc.)

Sparse Matrix Variables
-----------------------

If a variable's class type is sparse, the data field of the MATLAB variable structure is a pointer to the sparse matrix structure mat_sparse_t. The sparse matrix structure stores the non-zero elements of the matrix in compressed column format.

Structure Variables
-------------------

If the MATLAB variable structure's class_type is MAT_C_STRUCT, the data_type field should be MAT_T_STRUCT. The data field of the variable structure is a pointer to an array of matvar_t *. The length of the array is numel \times nfields where numel is the number of elements in the structure array (product of dimensions array), and nfields is the number of fields in the structure. The order of the variables in the array is first by field, and then by structure index. For example, for a 2 \times 1 structure array with 3 fields field1, field2, and field3, data field of the structure variable is ordered as:

s(1).field1

s(1).field2

s(1).field3

s(2).field1

s(2).field2

s(2).field3

Cell Variables
--------------

If the MATLAB variable structure's class_type is MAT_C_CELL, the data_type field should be MAT_T_CELL. The data field of the variable structure is a pointer to an array of matvar_t *. The length of the array is the product of the dimensions array. Each element of the cell array can be a different type.