# Structure Array in Matlab Programming

## Get Matlab Help Now..!

An array of structures is generally referred to as a struct array. Like other arrays in MATLAB, a struct array can have any dimensions. A structure array is a data type that groups the related data using the data containers called fields. Each field can contain any type of data. The data in a field can be accessed using dot notation of the form structName.fieldName.

A struct array has these properties:

• • All structs in the array possess same number of fields.

• • All structs possess the same field names.

• • Fields of the same name in different structs can have different types or sizes of data.

MATLAB provide various functions that can be use to create structure array.

s = struct

s = struct(field,value)

s = struct(field1,value1,...,fieldN,valueN)

s = struct([])

s = struct(obj)

s = struct makes a scalar (1-by-1) structure with no fields.

s = struct(field,value) creates a structure array with the defined field and values. The value input argument may be of any data type, such as a numeric, logical, character, or cell array. If the value is a nonscalar cell array, then s is a structure array with the same dimensions as that of value. Each element of s possess the corresponding element of value. For example, s = struct('x',{'a','b'},'y','c') gives back s(1).x = 'a', s(2).x = 'b', s(1).y = 'c', and s(2).y = 'c'.

s = struct(field1,value1,...,fieldN,valueN) creates various fields. Any nonscalar cell arrays in the set value1,...,valueN will have the same dimensions. If none of the value inputs by the user are cell arrays, or if all value inputs that are cell arrays are scalars, then s is a scalar structure.

s = struct([]) creates an empty (0-by-0) structure with no fields.

s = struct(obj) makes a scalar structure with field names and values corresponding to properties of obj. The struct function does not change obj, but rather makes s as a new structure. This structure does not possess the class information, so private, protected, and hidden properties become public fields in s. The struct function gives a warning when user use this syntax.