Structures
A structure array is a data type that groups related data using data
containers called fields. Each field can contain any type of data. Access
data in a structure using dot notation of the form
structName.fieldName
. For more information, see Structure Arrays or
watch Introducing Structures and Cell Arrays.
Functions
struct | Structure array |
fieldnames | Field names of structure, or public fields of Java or Microsoft COM object |
getfield | Field of structure array |
isfield | Determine if input is structure array field |
isstruct | Determine if input is structure array |
orderfields | Order fields of structure array |
rmfield | Remove fields from structure |
setfield | Assign value to structure array field |
arrayfun | Apply function to each element of array |
structfun | Apply function to each field of scalar structure |
table2struct | Convert table to structure array |
struct2table | Convert structure array to table |
cell2struct | Convert cell array to structure array |
struct2cell | Convert structure to cell array |
Topics
- Structure Arrays
Create a structure array and store data in its fields. Access the contents by name using array indexing and dot notation.
- Generate Field Names from Variables
Dynamically determine a structure field name at run time from a variable or expression.
- Ways to Organize Data in Structure Arrays
Consider ease of data access and system memory constraints when determining how to organize the data in a structure array.
- Memory Requirements for Structure Array
Structure arrays do not require contiguous memory, but their fields do. Instead of incrementally increasing the number of fields or number of elements in a field, preallocate memory for fields containing very large arrays.