How to access the data in cell and struct?

조회 수: 1 (최근 30일)
Yada Kijsathan
Yada Kijsathan 2023년 3월 28일
댓글: Yada Kijsathan 2023년 3월 29일
Hi
I have 1x984 cell, which consist of 984 (1x1) struct inside.
I woud like to get data from first column from each files contained in each struct.
I would be appreciated if someone can help me.
Many thanks!
  댓글 수: 2
Luca Ferro
Luca Ferro 2023년 3월 28일
could you please share the ref_files?
Yada Kijsathan
Yada Kijsathan 2023년 3월 28일
Hey.
Sure! but the file is quite big. I cannot upload here directly
Here is a link to download a file: https://we.tl/t-gcIvw2beC0

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

채택된 답변

Antoni Garcia-Herreros
Antoni Garcia-Herreros 2023년 3월 28일
Hello,
To access the contents in a cell you shoould use curly braces {}.
data=ref_files{idx,1}.asciiFile(:,1); % Data would be the first column of the idx cell
% If you want to create an array with the first column values of each
% struct try (assuming all your ascii data is the same length:
DATA=zeros(size(ref_files{1,1}.asciiFile(:,1),1),size(ref_files,2));
for i=1:size(ref_files,2)
DATA(:,i)=ref_files{i,1}.asciiFile(:,1);
end
Hope this helps!
  댓글 수: 1
Yada Kijsathan
Yada Kijsathan 2023년 3월 29일
I have adjusted something and it helps!
for idx = 1:984;
DATA(:,idx)=ref_files{1,idx}.asciiFile(:,1);
end
Thank you so much!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by