how do I concatenate mat files matlab
1 view (last 30 days)
Show older comments
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')
0 Comments
Accepted Answer
Voss
on 20 Dec 2023
Edited: Voss
on 21 Dec 2023
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 Comments
More Answers (0)
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!