Borrar filtros
Borrar filtros

How do I create an array from one field of an array of structs?

1 visualización (últimos 30 días)
I have an array of structs.
Each struct has following: name (string) value (double)
I want to create an array of names from names in each struct.
E.g. if I have a an array of structs called DateStruct I can do the following for i=1:25 NameArray(i) = DateStruct(i).name; end
But I want to achieve this through something like: NameArray = DateStruct(1:end).name;
When I do the above the NameArray is just 1x1 and prints only the first name.

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Feb. de 2011
NameArray = {DateStruct.name}

Más respuestas (0)

Categorías

Más información sobre Structures 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