question about structures in Matlab

 Réponse acceptée

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

4 commentaires

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by