How to write the matlab command for creating the nested structures ?

1 visualización (últimos 30 días)
CHV
CHV el 17 de Mayo de 2019
Comentada: CHV el 19 de Mayo de 2019
Hello,
I want to write the single Matlab command for creating the nested structures as below, instead of two commands (like a = struct(...))
a.b(1).c = struct('d',{1,2,3},'e',{4,5,6})
a.b(2).c = struct('f',{7,8,9},'g',{4,5,6})

Respuesta aceptada

Guillaume
Guillaume el 17 de Mayo de 2019
In my opinion, you're better off sticking with what you have. It's a lot clearer than the one-liner. If you really want the one-liner, it's more of the same as what you've already written:
a = struct('b', struct('c', {struct('d',{1,2,3},'e',{4,5,6}), struct('f',{7,8,9},'g',{4,5,6})}))

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by