MATLAB 帮助中心
本页翻译不是最新的。点击此处可查看最新英文版本。
按名称查找单个工程文件
从 R2024a 开始,请使用 findFiles 而不是 findFile 以获得更灵活的解决方案。findFiles 提供高级搜索功能,包括按标签、类别等查找文件。
findFiles
findFile
file = findFile(proj,fileOrFolder)
file = findFile(proj,fileOrFolder) 从指定工程中获取具有指定路径的文件。
file
proj
fileOrFolder
示例
全部折叠
打开 Times Table App 工程。使用 currentProject 从当前加载的工程创建一个工程对象。
currentProject
openExample("matlab/TimesTableProjectExample") proj = currentProject;
使用 findFile 按名称获取文件。如果文件位于工程根目录的子文件夹中,则需要指定完整路径。
myfile = findFile(proj,"source/timesTableGame.m")
myfile = ProjectFile with properties: Path: "C:\myProjects\examples\TimesTableApp\source\timesTableGame.m" Labels: [1×1 matlab.project.Label] Revision: "734fbb2f815848e22694d9ac7ea28953d5e42635" SourceControlStatus: Unmodified
您也可以通过索引获取文件。获取第一个文件。
file = proj.Files(1);
了解您可以使用该文件做什么。
methods(file)
Methods for class matlab.project.ProjectFile: addLabel findLabel removeLabel
matlab.project.Project
工程,指定为 matlab.project.Project 对象。使用 currentProject 从当前加载的工程创建一个工程对象。
要查找的文件或文件夹的路径,指定为字符向量或字符串标量。指定的值必须为从工程根目录到文件的完整路径,包括任何子文件夹的名称。它还必须包括文件扩展名。文件或文件夹必须在根文件夹中。
ProjectFile
工程文件,返回可查询或修改的 ProjectFile 对象。
在 R2019a 中推出
currentProject | openProject | findFiles | addLabel | removeLabel | findCategory | findLabel
openProject
addLabel
removeLabel
findCategory
findLabel
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处