how to import data from multiple folders in matlab?

5 次查看(过去 30 天)
I have my data in multiple folders. let say i have a folder containing 3 subfolders at the moment that look like this
/folder/Re0001/vitesse
/folder/Re0002/vitesse
/folder/Re0003/vitesse
i want to import the vitesse file in to cell array. this is the code that i am using at the moment
*numfiles=3;
mydata=cell(1,numfiles);
for i=1:numfiles
mydata{i}=uiimport;
end*
##really appreciate if u can help me. I am stuck with this for almost 3 days. thanks

回答(1 个)

Muthu Annamalai
Muthu Annamalai 2013-7-1
I don't understand your question. You seem to already have a working solution.
filenames = {'path/1/fil1', ... }
numfiles= length(filenames);
mydata=cell(1,numfiles);
for i=1:numfiles
mydata{i}=load( filename{numfiles} );
end
If you want to access filenames dynamically you can use the dir() command.
q = dir('./')
filenames = {q.name}
You don't have a choice except for specifying the files to look for with load. Its a simple task to do.
  1 个评论
bu
bu 2013-7-1
yes it is a working solution however, if it involves like 100 or more files i have to specify each folders and files manually. it is very troublesome. By the way I am new to matlab so can you please incorporate example code with the directory given.
i dont understand the
filenames = {'path/1/fill', ...}
and
q = dir('./') filenames = {q.name}
thanks for the quick reply.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by