Azzera filtri
Azzera filtri

how to find the length of a directory

5 visualizzazioni (ultimi 30 giorni)
Animesh
Animesh il 21 Dic 2013
Risposto: Jos (10584) il 21 Dic 2013
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

Risposta accettata

Jos (10584)
Jos (10584) il 21 Dic 2013
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).

Più risposte (0)

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by