필터 지우기
필터 지우기

how to find the length of a directory

조회 수: 5 (최근 30일)
Animesh
Animesh 2013년 12월 21일
답변: Jos (10584) 2013년 12월 21일
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

채택된 답변

Jos (10584)
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개)

카테고리

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