ls函数
List folder contents
Syntax
ls
ls name
list = ls(___)
Description
ls lists the contents of the current folder.
ls name lists the files and folders in the current folder that match the specified name.
list = ls(___) returns the names of all the files and folders in the current folder that match the specified name. You can specify list with any of the arguments in the previous syntaxes.
Examples
List Files and Folders
List all the files and folders with names that contain my.
>> ls *my*
my_class.m my_function.m my_script.m my_text.txt
List all the files and folders with a .m extension.
>> ls *.m
my_class.m my_function.m my_script.m test_function.m
Save List of Files and Folders
Save a list of the names of all the files and folders in the current folder to the variable MyList.
MyList = ls;