question about structures in Matlab

 채택된 답변

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에 대해 자세히 알아보기

태그

질문:

2011년 11월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by