reading string from a cell for importing data
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Sarah Wait Zaranek
2011-3-5
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!