フィルターのクリア

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 Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by