Struct Operations¶
struct¶
Syntax
s = struct
s = struct(fieldname1,value1,…,fieldnameN,valueN)
s = struct([])
Description
This operation returns struct arras with the specified fields and values.
- The form
structreturns a 1 by 1 struct array with no fields.- The form
struct(fieldname1,value1,…,fieldnameN,valueN)returns a struct array with the given field and values. If any of the field or values provided or non-scalar, then the dimensions of all the non-scalar field and values should be the same, and the array returned will have the non-scalar dimension.- The form
struct([])returns a 0 by 0 empty struct array with no fields.
fieldnames¶
Syntax
fieldnames(s)
Description
Given a struct or struct array, this returns the names of the fields as a cell array.
isfield¶
Syntax
tf = isfield(S, 'field')
tf = isfield(S, C)
This function determines if a structure array contains the given field name(s).
- The first form takes a single field name and returns a scalar logical value which is true if the structure array contains the given field name, and false otherwise.
- The second form accepts a structure array and a cell array of character vectors, each indicating a field name. The return value of the function is a logical array with the same dimensions as the cell array, containing a logical value indicating, for each field name, if that field is present in the given structure array.
isstruct¶
Syntax
tf = isstrut(A)
This function determines if a value is a scalar or array of structures. It returns a scalar true if so, and false otherwise.
rmfield¶
Syntax
s = rmfield(s,field)
This function removes the named field or fields from the structure
array s and returns the modified result. field should either
be a single field name, or a cell array of field names.
getfield¶
Syntax
value = getfield(s, field)
This function extracts the value of the named field from the
scalar structure s.
MATLAB supports more complicated forms of the getfield function,
but these forms are not currently supported by Grackle.
setfield¶
Syntax
s = setfield(s,field,value)
Set the value of field in scalar structure s to value,
returning the modified result. field should be a character array
denoting a field name.
MATLAB supports more complicated forms of the setfield function,
but these forms are not currently supported by Grackle.