how to import and combine multiple.mat files into one big matrix??

조회 수: 10 (최근 30일)
chad
chad 2014년 4월 4일
편집: Azzi Abdelmalek 2014년 4월 5일
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.

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 4일
편집: Azzi Abdelmalek 2014년 4월 5일
EDIT
for k = 1:numfiles
mydata{k} = data(k).name;
data{k}=load(mydata{k})
end
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 4일
편집: Azzi Abdelmalek 2014년 4월 5일
for k = 1:numfiles
mydata{k} = data(k).name;
data{k}=load(mydata{k})
end
chad
chad 2014년 4월 5일
thanks for the reply! although this code gives the error message: argument must contain string for the line: data{k}=load(mydata{k}) does it matter that all the data in my data sets are ints?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by