struct
创建结构数组
Syntax
s = struct
s = struct(字段,值)
s = struct(field1,value1,...,fieldN,valueN)
s = struct([])
s = struct(obj)
Description
s = struct
创建一个没有字段的标量(1-by-1)结构。
s = struct(
使用指定的字段和值创建一个结构数组。这field
,价值
)价值
输入参数可以是任何数据类型,例如数字,逻辑,字符或单元格数组。
If
价值
isnot然后一个单元格数阵列s
is a scalar structure, wheres。(字段)=值
。If
价值
is a cell array, thens
is a structure array with the same dimensions as价值
。每个元素s
contains the corresponding element of价值
。For example,s = struct('f',{'a','b'})
returnss(1).f = 'a'
和s(2).f = 'b'
。If
价值
是一个空的单元格数组{}
, thens
是一个empty (0-by-0) structure.
s = struct(field1,value1,...,fieldN,valueN)
creates a structure array with multiple fields. Any nonscalar cell arrays in the setValue1,...,Valuen
必须具有相同的维度。
如果没有
价值
inputs is a cell array, or if all价值
inputs that are cell arrays are scalars, thens
是标量结构。如果有
价值
inputs is a nonscalar cell array, thens
具有与非尺度单元阵列相同的尺寸。任何价值
that is a scalar cell array or an array of any other data type,struct
插入的内容价值
in the relevant field for all elements ofs
。If any
价值
输入是一个空的单元格数组,{}
, then outputs
是一个empty (0-by-0) structure. To specify an empty field and keep the values of the other fields, use[]
作为一个价值
输入。
s = struct([])
创建一个没有字段的空结构(0 x-0)结构。
s = struct(
创建具有字段名称和值的标量结构,与obj
)obj
。这struct
function does not convertobj
,而是创造s
作为一个new structure. This structure does not retain the class information, so private, protected, and hidden properties become public fields ins
。这struct
function issues a warning when you use this syntax.
Examples
Input Arguments
Extended Capabilities
看Also
cell2struct
|字面名称
|isfield
|isstruct
|Orderfields
|rmfield
|struct2cell
|struct2table
|子结构
|桌子
|桌子2struct