Extracting values from struct array

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?

回答(1 个)

{one.C}
This would produce a 1 x 98 cell, each entry of which contained a 2 x 2 x 56 matrix.

3 个评论

This gives out an error: "Struct contents reference from a non-struct array object."
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

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by