how to import and combine multiple.mat files into one big matrix??
5 views (last 30 days)
Show older comments
i would like to import and combine the contents of 20 .mat files (4 columns per file, all cells are ints) from the same folder into one long data array so that i can analyze each of the four columns by row (line by line). the wiki examples show how to import multiple jpeg and text files, and the video on here, 'how to import files programmatically', uses excel files as an example, but nothing about combining and importing multiple .mat files. this should be simple, but im a novice and im learning on my own. can someone point me in the right direction or show me how i would do this with a for loop?
so far i have
data = dir('../.mat');
numfiles = length(data);
mydata = cell(1, numfiles);
for k = 1:numfiles
mydata{k} = matfile(data(k).name);
end
which gives me the files in the folder but not their contents.
0 Comments
Answers (1)
Azzi Abdelmalek
on 4 Apr 2014
Edited: Azzi Abdelmalek
on 5 Apr 2014
EDIT
for k = 1:numfiles
mydata{k} = data(k).name;
data{k}=load(mydata{k})
end
2 Comments
Azzi Abdelmalek
on 4 Apr 2014
Edited: Azzi Abdelmalek
on 5 Apr 2014
for k = 1:numfiles
mydata{k} = data(k).name;
data{k}=load(mydata{k})
end
See Also
Categories
Find more on Data Import and Analysis 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!