採用された回答

Sven
Sven 2011 年 11 月 14 日

0 投票

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

4 件のコメント

Walter Roberson
Walter Roberson 2011 年 11 月 14 日
Or more compactly,
s = struct('field1', 45, 'field2', 'Nothing', 'field3', struct('subfield1', 232))
Walter Roberson
Walter Roberson 2011 年 11 月 14 日
Nested structures are fairly common.
Sven
Sven 2011 年 11 月 14 日
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?
ssklios Sklios
ssklios Sklios 2011 年 11 月 14 日
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