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

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 8월 7일
편집: Azzi Abdelmalek 2014년 8월 7일

0 개 추천

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
Michael Haderlein 2014년 8월 7일

0 개 추천

Just specify your dir query:
list_files2load = dir(fullfiles(directory1,'Mod1*00k.txt'));

댓글 수: 1

Nicolas
Nicolas 2014년 8월 7일
that is good idea as well, didn't know I could do that ! selecting the '00k.txt' would be the first loop, then I would pick the '*10k.txt' and so on. So i think the answer of Azzi fits me better.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

태그

질문:

2014년 8월 7일

댓글:

2014년 8월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by