dir([num2str(d) '\*.png']

조회 수: 9 (최근 30일)
Umer  Lilla
Umer Lilla 2018년 6월 29일
댓글: Shanuka Jayasinghe 2020년 4월 14일
dir([num2str(d) '\*.png']
Any one can tell me what is happening over here?

답변 (1개)

Stephen23
Stephen23 2018년 6월 29일
편집: Stephen23 2018년 6월 29일
It searches for files name with the file extension .png that are located in the directory d.
dir([num2str(d) '\*.png']
'\*.png' % character vector
num2str(d) % convert |d| to character
[ ] % horizontally concatenate the two character vectors
dir( ) % call DIR
Better would be to use fullfile:
dir(fullfile(num2str(d),'*.png'))
  댓글 수: 3
Walter Roberson
Walter Roberson 2020년 4월 14일
for the case where d = 'string' it searches for files in the current directory that match the file name 'string*.png'
No, it does not. Not that code. If you wanted that to happen, you would need to use '*.png' instead of '\*.png'
Shanuka Jayasinghe
Shanuka Jayasinghe 2020년 4월 14일
Thanks for the reply!
I had also posted a question on reddit, and a user pointed out that i could use the strcat command.
I found that example to work for my specific case, but maybe this will help someone else as well.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by