How to access the data in cell and struct?
2 ビュー (過去 30 日間)
古いコメントを表示
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!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1338439/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1338444/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1338449/image.jpeg)
2 件のコメント
採用された回答
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!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!