'DATA' is a 1x1 struct containing 217 fields. Each field is a structure containing a double array labelled 'data'.
I would like to concatenate the 'data' array in each of the 217 fields into one vector.
The structure containing the dat ais attached
any help would be greatly appreciated.

답변 (1개)

David Hill
David Hill 2021년 10월 28일

0 개 추천

z=[];
for k=1:217
s=sprintf('DATA.Segment%d.data',k);
z=[z;eval(s)];
end

댓글 수: 2

great! Thanks a million
Akira Agata
Akira Agata 2021년 11월 1일
편집: Akira Agata 2021년 11월 1일
+1
The following way can avoid 'eval' function:
load("lvm2matDATA.mat");
% Extract field names containing "Segment"
list = fieldnames(DATA);
list = list(contains(list,"Segment"));
% Concatenate data
tData = [];
for kk = 1:numel(list)
tData = [tData, DATA.(list{kk}).data];
end
% Arrange it as a table variable
tData = array2table(tData,"VariableNames",list);

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 10월 28일

편집:

2021년 11월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by