How to merge multiple xyz files into 1 large array

3 ビュー (過去 30 日間)
Yoni Verhaegen -WE-1718-
Yoni Verhaegen -WE-1718- 2019 年 10 月 21 日
回答済み: meghannmarie 2019 年 10 月 21 日
I have a set of 501 XYZ files which I load in as
for k = 1:501
% AIS SEC data
AIS_SEC{k} = importdata(['AIS_SEC(' num2str(k) ').xyz']);
end
This generates an 1x501 cell array in which all data are stored (see attachment). How can I merge all these data to have 1 large XYZ file?
For example, to concentrate X data, I tried:
for k = 1:501
my_field = sprintf('X%d', k);
variable.(my_field) = ([AIS_SEC{1,k}.data(:,1)]);
end
BUT: Dot indexing is not supported for variables of this type.
Thanks!

回答 (1 件)

meghannmarie
meghannmarie 2019 年 10 月 21 日
Not all the cells in AIS_SEC are structures. For example AIS_SEC{1,33} is a cell array with a string in it.
You can skip those cells:
for k = 1:501
my_field = sprintf('X%d',k);
x = AIS_SEC{1,k};
if isstruct(x)
variable.(my_field) = ([x.data(:,1)]);
end
end

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by