How can I select specific text files ?
1 次查看(过去 30 天)
显示 更早的评论
I have imported a bench of text file into MATLAB using
list_files2load = dir(fullfile(directory1,'Mod1*));
But then in those files (here is an example: Mod1-A-00k.txt, Mod1-A-10k.txt, Mod1-A-30k.txt; Mod1-B-00k.txt, Mod1-B-10k.txt, Mod1-B-30k.txt), I would like to pick only the ones that end with '*00k.txt'
how could I do that?
Thanks
0 个评论
采纳的回答
Azzi Abdelmalek
2014-8-7
编辑:Azzi Abdelmalek
2014-8-7
a={'Mod1-A-00k.txt', 'Mod1-A-10k.txt', 'Mod1-A-30k.txt', 'Mod1-B-00k.txt', 'Mod1-B-10k.txt', 'Mod1-B-30k.txt'}
idx=~cellfun(@isempty,regexp(a,'.+(?=00k.txt).+','match'))
b=a(idx)
%or
idx=~cellfun(@isempty,regexp(a,'.+(00k.txt)\>','match'))
b=a(idx)
更多回答(1 个)
Michael Haderlein
2014-8-7
Just specify your dir query:
list_files2load = dir(fullfiles(directory1,'Mod1*00k.txt'));
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!