Extracting values from struct array
Afficher commentaires plus anciens
I have an struct array "one" = 98 x 1 cell. Each of these 98 rows has a field "C" with some values (2 x 2 x 56) complex double. How can I extract the value of "C" from all these 98 rows at once and save in a new variable?
Réponses (1)
Walter Roberson
le 24 Jan 2018
{one.C}
This would produce a 1 x 98 cell, each entry of which contained a 2 x 2 x 56 matrix.
3 commentaires
Syed Ayaz Mahmud
le 24 Jan 2018
Walter Roberson
le 24 Jan 2018
You said that "one" is a struct array, but you also say it is a cell ?? Is it a cell array in which each element is a scalar struct? If so then
cellfun(@(S) S.C, one, 'uniform', 0)
This gives out an error: "Struct contents reference from a non-struct array object."
Then what you have is not a struct array as your question states. You can read about struct arrays in the MATLAB documentation: https://www.mathworks.com/help/matlab/matlab_prog/access-multiple-elements-of-a-nonscalar-struct-array.html
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!