List folder contents
ls lists the contents of the current folder.
List all the files and folders with names that contain
my_class.m my_function.m my_script.m my_text.txt
List all the files and folders with a
my_class.m my_function.m my_script.m test_function.m
Save a list of the names of all the files and
folders in the current folder to the variable
MyList = ls;
name— Name of file or foldercharacter vector
Name of file or folder, specified as a character vector. Use
'*' wildcard to match patterns. For example,
*.m lists all files and folders with a
ls m* lists all files and folders with names
that begin with the letter
list— List of files and folderscharacter array
List of files and folders, specified as a character array in one of these formats.
UNIX® platforms –
a character vector of names separated by tab and space characters.
Microsoft® Windows® platforms –
n character array of
m is the number of names and
the number of characters in the longest name. MATLAB® pads names
n characters with space characters.
dir command to
return file attributes for each file and folder in the output argument.
You can also view files and folders in the Current
Folder browser by issuing the