vertically concatenate struct values from the same field

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 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

製品

リリース

R2019b

質問済み:

2020 年 7 月 27 日

編集済み:

2022 年 2 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by