필터 지우기
필터 지우기

Reading files in a specified order

조회 수: 3 (최근 30일)
L'O.G.
L'O.G. 2022년 3월 29일
편집: Stephen23 2022년 3월 29일
I have multiple files of the same type in a directory that all have the same beginning, say "A11_K", followed by a numbers specific to the file. For example
A11_K25-1.txt
A11_K25-2.txt
A11_K27-1.txt
I know I can read all of the files of that type using something like files = dir('A11_K*') but how do I make sure I read them, in the numeric order following the K above as in the example list?

채택된 답변

Stephen23
Stephen23 2022년 3월 29일
편집: Stephen23 2022년 3월 29일
Download NATSORTFILES here:
and use it like this:
S = dir('A11_K*.txt');
S = natsortfiles(S);

추가 답변 (1개)

Fangjun Jiang
Fangjun Jiang 2022년 3월 29일
>> sort({'A11_K25-2.txt','A11_K27-1.txt','A11_K25-1.txt'})
ans =
1×3 cell array
{'A11_K25-1.txt'} {'A11_K25-2.txt'} {'A11_K27-1.txt'}

카테고리

Help CenterFile Exchange에서 Downloads에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by