User`s manual

1 Calling C and Fortran Programs from MATLAB
1-6
MATLAB Data
Before you can program MEX-files, you must understand how MATLAB
represents the many data types it supports. This section discusses the
following topics:
“The MATLAB Array”
“Data Storage”
“Data Types in MATLAB”
“Using Data Types”
The MATLAB Array
The MATLAB language works with only a single object type: the MATLAB
array. All MATLAB variables, including scalars, vectors, matrices, strings, cell
arrays, structures, and objects are stored as MATLAB arrays. In C, the
MATLAB array is declared to be of type
mxArray. The mxArray structure
contains, among other things:
Its type
Its dimensions
The data associated with this array
If numeric, whether the variable is real or complex
If sparse, its indices and nonzero maximum elements
If a structure or object, the number of fields and field names
Data Storage
All MATLAB data is stored columnwise, which is how Fortran stores matrices.
MATLAB uses this convention because it was originally written in Fortran. For
example, given the matrix
a=['house'; 'floor'; 'porch']
a =
house
floor
porch