vertically concatenate struct values from the same field

3 次查看(过去 30 天)
Hi I encountered an issue in vertically concatenation of struct values from the same field. e.g. given S1
[S1(1:10).vals] = deal([1,2,3])
what I want to achieve is to extract all values from the field 'vals' of struct 'S1'. I could do it in a for loop so that
t= [];
for i = 1: 10
t = [t;S1(i).vals];
end
Since such commands appears frequently, is there a neater code for this purposes using structfun?
Any suggestion would be appreciated!

采纳的回答

Stephen23
Stephen23 2020-7-27
编辑:Stephen23 2022-2-23
  1 个评论
Rupeng Li
Rupeng Li 2020-7-27
编辑:Rupeng Li 2020-7-27
Thanks! that's very neat. Also thanks for your supplementary materials. The comma seperated list looks powerful.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by