Create and Edit Projects Programmatically
This example shows how to use the Project API to create a new project and automate
project tasks for manipfulating files. It covers how to create a project from the command
line, add files and folders, set up the project path, define project shortcuts, and create a
reference to the new project in another project. It also shows how to programmatically
work with modified files, dependencies, shortcuts, and labels.
Set up the Example Files
Create a working copy of the Times Table App example project files and open the project.
MATLAB® copies the files to an examples folder so that you can edit them. The project
puts the files under Git™ source control. Use currentProject to create a project object
from the currently loaded project.
matlab.project.example.timesTable
mainProject = currentProject;
Examine Project Files
Examine the files in the project.
files = mainProject.Files
files =
1×14 ProjectFile array with properties:
Path
Labels
Revision
SourceControlStatus
Use indexing to access files in this list. For example, get file number 10. Each file has
properties describing its path and attached labels.
mainProject.Files(10)
ans =
ProjectFile with properties:
Path: "C:\MATLAB\Projects\examples\TimesTableApp1\tests\tNewTimesTable.m"
Labels: [1×1 matlab.project.Label]
Revision: ""
31 Projects