-1

I have my data in multiple folders. Let's say I have a folder containing 100 subfolders at the moment that look like this:

/folder/Re0001/vitesse
/folder/Re0002/vitesse
/folder/Re000N/vitesse
/folder/Re000N+1/vitesse
/folder/Re0100/vitesse

I want to import the vitesse file into a cell array. This is the code that i am using at the moment:

numfiles=100;

mydata=cell(1,numfiles);

for i=1:numfiles

    mydata{i}=uiimport;

end

It is a working solution.

However, if it involves 100 or more files I have to specify each folders and files manually, which is very troublesome.

By the way I am new to Matlab so can you please incorporate example code with the directory given.

Schorsch
  • 7,761
  • 6
  • 39
  • 65
  • 2
    Check [this question/answer](http://stackoverflow.com/questions/2652630/how-to-get-all-files-under-a-specific-directory-in-matlab) – Schorsch Jul 01 '13 at 15:27

1 Answers1

0

I did something similar few days ago. Have a look at the matlab function ls. If you are using windows system, you are all set. If your are using linux, you may need to split the results. However newer version of matlab have the strsplit function that will do the job, or you will use regular expressions. In your case,

list = ls('/folder/*/vitesse');

will give you a list of your files.

innoSPG
  • 4,588
  • 1
  • 29
  • 42