Accessing values from struct array
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have a giant struct array with fields: f1, f2, f3. i.e. Struct Array: StAr(i) has StAr(i).f1, StAr(i).f2,StAr(i).f3. But I want to create a new Array by just collecting all the f1 values without using a for loop. How do I achieve this?
Thanks guys
0 comentarios
Respuesta aceptada
Más respuestas (1)
Wayne King
el 15 de Oct. de 2012
Editada: Wayne King
el 15 de Oct. de 2012
data = getfield(structarrayname,'f1');
For example:
mystruct = struct('f1',randn(100,1),'f2',randn(100,1),'f3',randn(100,1));
data = getfield(mystruct,'f1');
Ver también
Categorías
Más información sobre Structures en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!