Merging several mat files in a row order

1 回表示 (過去 30 日間)
Ahmet Hakan UYANIK
Ahmet Hakan UYANIK 2021 年 7 月 11 日
コメント済み: Jan 2021 年 7 月 15 日
Hi everyone,
I have 65 mat files with different names and each mat file is 1x1 struct, contains information as longitude, latitude, year(335x1), month(335x1) etc.
So how can i combine them as a single mat file which should have first row as a information of first mat file, second row as a information of second mat file, until 65 rows of each mat file?
I would be very pleased if you have any idea about how to do it?

回答 (1 件)

Jan
Jan 2021 年 7 月 11 日
You did not explain, how a list of the files names can be obtained. I guess, that they can be found in the same folder:
Folder = 'C:\your\folder';
Files = dir(fullfile(Folder, '*.mat'));
DataC = cell(1, numel(Files));
for iFile = 1:numel(Files)
aFile = fullfile(Folder, Files(iFile).name);
DataC{iFile} = load(aFile);
end
Data = cat(2, DataC{:});
  4 件のコメント
Ahmet Hakan UYANIK
Ahmet Hakan UYANIK 2021 年 7 月 14 日
files contains structs with a field name and with subfields of longitutde latitude datetime and observation as well. Expected output is having one mat file that each file with its subfields in a row, so that i can just call with the row order.
Has it become more clear?
Jan
Jan 2021 年 7 月 15 日
What are "subfields in a row"? Fields do not have an orientation. What is "calling with the row order"?
I assume, you want to create either a struct array, or to write a text file containing rows.

サインインしてコメントする。

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by