how do I concatenate mat files matlab

2 ビュー (過去 30 日間)
Muhammad Usman
Muhammad Usman 2015 年 3 月 20 日
コメント済み: Voss 2023 年 12 月 21 日
I have hundreds of MAT files and i want to concatenate all these files to a single file,each MAT file has dimension of 69x128,here is the technique that I follwed before for fewer files but this is not comfortable for me please provide some comformtable and simpler way to dothe same job
a1=load(sprintf('datafile_%02d',1));
a2=load(sprintf('datafile_%02d',2));
P1 = a.dataselection(:,5:132);
P2 = a2.dataselection(:,5:132);
PO = [P1;P2];
save('PO')
load('PO')

採用された回答

Voss
Voss 2023 年 12 月 20 日
編集済み: Voss 2023 年 12 月 21 日
N = 200; % number of files (assumed to be named datafile_01.mat, _02.mat, ..., _10.mat, ..., _99.mat, _100.mat, ..., as you have specified with '%02d')
C = cell(1,N);
for ii = 1:N
A = load(sprintf('datafile_%02d.mat',ii));
C{ii} = A.dataselection(:,5:132);
end
PO = vertcat(C{:});
save('PO.mat','PO')
  4 件のコメント
Stephen23
Stephen23 2023 年 12 月 21 日
Accepted, as it seems to answer the question.
Voss
Voss 2023 年 12 月 21 日
I appreciate it!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by