reading string from a cell for importing data

3 Ansichten (letzte 30 Tage)
minoo
minoo am 23 Feb. 2011
Hi all,
I'd like to open several folders and sub-folders to import my data. I;ve found a function named "allfiles" and it reads all the data in folders and sub-folders and save them in a cell in string format. now I want to read from this cell and import data. The "allfiles" function returns all files below a directory with given extensions
% LIST = ALLFILES(DIR, EXT) finds all the files in the directory DIR or % one of its subdirectories (defined recursively) with an extension in % the list EXT. DIR must be a string. EXT may be a string to specify a % single extension, or a cell array of strings. The leading '.' in the % extension is omitted. The result is a cell array of strings. %
% Example: % filenames = allfiles('.', {'m' 'asv'}); % finds all the .m and .asv files in or below the current directory.
as you see in the function above, the directories of data are saved in cell and if I can read these directories and import the correspond data I've done my work!
could you help me to do this?
thanks in advance

Akzeptierte Antwort

Sarah Wait Zaranek
Sarah Wait Zaranek am 5 Mär. 2011
cellfun will probably be the easiest way to do this for you. cellfun will allow you to run a particular function on every element of a cell. See my code below to get started:
ReadData = cellfun(@(x) yourreadfunction(x), filenames, 'UniformOutput',false)
Note: I am not sure what function you are using to read your data so I just put yourreadfunction is place of what you would use. If you don't know what read function to use, I find the below chart useful.
This is a link to the documentation for cellfun.

Weitere Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by