Using the C++ Math Library    

MATLAB Structures

A MATLAB structure can be thought of as a one-dimensional cell array in which each cell is assigned a name. These named cells are called fields. You can create multidimensional arrays of structures; all the structures in an array of structures must have the same fields.

The following table lists the MATLAB C++ Math Library routines to create structures and perform basic tasks with them. The sections that follow provide more detail about using these routines. For more detailed information about using structures, see Using MATLAB. For more detailed information about any of the library routines, see the MATLAB C++ Math Library Reference.

Table 3-5: MATLAB Structure Routines
To ...
Use ...
Create a structure an initialize it with values.
struct_func()
Convert a cell array into a structure.
cell2struct()
Determine the names of the fields in a structure.
fieldnames()
Determine if a string is the name of a field in a structure.
isfield()
Access the contents of a field in a structure.
getfield()
Specify the value of a field in a structure.
setfield()
Remove a field from each structure in an array of structures.
rmfield()


 Displaying the Contents of a Cell Array Creating Structures