how to import data from multiple folders in matlab?

1 vue (au cours des 30 derniers jours)
bu
bu le 1 Juil 2013
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

Réponses (1)

Muthu Annamalai
Muthu Annamalai le 1 Juil 2013
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 commentaire
bu
bu le 1 Juil 2013
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by