MATLAB Function Reference    

Display directory listing

Graphical Interface

As an alternative to the dir function, use the Current Directory browser.



dir lists the files in the current working directory.

dir name lists the specified files. The name argument can be a pathname, filename, or can include both. You can use absolute and relative pathnames and wildcards (*).

files = dir('directory') returns the list of files in the specified directory (or the current directory, if dirname is not specified) to an m-by-1 structure with the fields

Modification date
Number of bytes allocated to the file
1 if name is a directory; 0 if not


List Directory Contents

To view the contents of the matlab/audio directory, type

Using Wildcard and File Extension

To view the MAT files in your current working directory that include the term java, type

MATLAB returns

Using Relative Pathname

To view the M-files in the MATLAB audio directory, type

MATLAB returns

Returning File List to Structure

To return the list of files to the variable audio_files, type

MATLAB returns the information in a structure array.

Index into the structure to access a particular item. For example,

See Also
cd, copyfile, delete, fileattrib, filebrowser, ls, mkdir, movefile, rmdir, type, what

  diff disp