how to import data from multiple folders in matlab?

5 ビュー (過去 30 日間)
bu
bu 2013 年 7 月 1 日
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 Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by