Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

consolidate all fields in a structure

3 visualizaciones (últimos 30 días)
hdg D
hdg D el 21 de Ag. de 2013
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
hello, This agian is a consolidation question if I have a set of fields in a structure
say I have a structure mystruct which is a 1x2
struct array with fields
='id'
'name'
'age'
..etc
but say my field name has fields too so
fields(mystruct.name)
=
'lastname'
'firstname'
and perhaps my firstname could have additonal fields
fields(mystruct.name.firstname)
='nickname'
At the end I want to consolidate all this information into a single BigStruct
BigStruct.name.firstname = [mystruct(1).name.firstname, mystruct(2).name.firstname ..etc]
BigStruct.name.lastname = [mystruct(1).name.lastname, mystruct(2).name.lastname ..etc]
BigStruct.id =[mystruct(1).id, mystruct(2).id ..]
The assumption is they are all the same length so they can be concatenated.. How do I do this without having to specifiy each field or sub fields
Thanks so much! HD

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by