storing filenames from directory
12 次查看(过去 30 天)
显示 更早的评论
I would like to store filenames from a directory in a matrix. Filenames are of the following format:
11_1200.12.X
11_1201.37.X
11_1202.67.X
...
采纳的回答
Walter Roberson
2011-11-3
fileinfo = dir('*.X');
fnames = {fileinfo.name};
Now fnames{1}, fnames{2} and so on will be the file names.
Note: the list will not necessarily be sorted. Use sort({fileinfo.name}) if you need it sorted.
2 个评论
Walter Roberson
2011-11-4
namepart = cellfun(@(S) S(4:7), fnames, 'Uniform', 0);
If you prefer it in numeric form, you can use
namepart = cellfun(@(S) str2double(S(4:7)), fnames);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!