reading string from a cell for importing data
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuesta aceptada
Sarah Wait Zaranek
el 5 de Mzo. de 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.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!