question about structures in Matlab

 采纳的回答

Yes, that's possible:
s = struct('field1', 45, 'field2', 'Nothing')
s.field3 = struct('subfield1', 232)
And you can access:
s.field3.subfield1

4 个评论

Or more compactly,
s = struct('field1', 45, 'field2', 'Nothing', 'field3', struct('subfield1', 232))
Nested structures are fairly common.
Yes, as Walter points out, you can put a structure within a structure even in one line, whereas my answer tries to separate things for clarity over compactness.
Was this your question ssklios?
yes it was. I am trying to do a MEX file for C code that uses structures within structures so I wanted to make sure this could be accomplished in matlab.

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Structures 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by