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;
本文介绍如何使用ls函数来列举当前文件夹中的所有文件和子文件夹,包括通过指定名称模式过滤显示特定文件。文章还展示了如何保存列举出的文件和文件夹列表到变量中。
317





