how to find the length of a directory
조회 수: 9 (최근 30일)
이전 댓글 표시
I have a folder in which my images are saved.I want to find the no. of .tif files stored in the directory. I wrote j=length(dir(['E:\IMAGES\*.tif'])); It shows an error Index exceeds matrix dimensions Please can anyone explain this?
Folder Name : E:\IMAGES File name image_####.tif where #### is any four digit number
THANKS IN ADVANCE
댓글 수: 0
채택된 답변
Jos (10584)
2013년 12월 21일
The error is most likely to the fact there is variable called dir (or, less likely, length) in your workspace. Try this
which dir
which length
To reproduce the error:
clear dir
dir('*.*')
dir = 1:4 ;
dir('*.*')
which gives the error " ??? Index exceeds matrix dimensions. ". The reason is that the last line is looking for the 42nd element of the vector dir, which has only four elements. (the ascii code of '*' is 42).
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!