concatenating several mat file into one
9 views (last 30 days)
Show older comments
Hi,
I have several mat file like: first.mat ,second.mat ,third.mat,...
all of these files have the same content like: variable1<3400x1 double> , variable2<1143x1 double> , variable3<1141x1 double> , ...
all mat files have the same content but the size of each variable in each mat file is different. I need to concatenate all same variables in all mat files in order to have just one mat file.
can somebody tell me what can I do?which function should I use?
Many thanks.
0 Comments
Accepted Answer
dpb
on 13 Apr 2014
Presuming by "math" files you mean a Matlab .mat file,
d=dir('*.mat'); % get the list of files
x=[]; % start w/ an empty array
for i=1:length(d)
x=[x; load(d(i).name)]; % read/concatenate into x
end
save('newfile.mat',x)
More Answers (0)
See Also
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!