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

카테고리

도움말 센터 및 File Exchange에서 Structures에 대해 자세히 알아보기

제품

릴리스

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