Explore an Example Project

This example uses the Times Table App example project to explore how project tools can help you organize your work.

Using the Times Table App example, we will explore how to:

  1. Set up and browse some example project files under source control.

  2. Examine project shortcuts to access frequently used files and tasks.

  3. Analyze dependencies in the project and locate required files that are not yet in the project.

  4. Modify some project files, find and review modified files, compare them to an earlier version, and commit modified files to source control.

  5. Explore views of project files only, modified files, and all files under the project root folder.

Setup 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.

matlab.project.example.timestable

View, Search, and Sort Project Files

You can view, search, and sort project files by using theFilesview.

To view the files in the project, in theFilesview, clickProject (number of files)。When the view is selected, only the files in your project are shown.

To see all the files in your project folder, clickAll。This view shows all the files that are under the project root, not just the files that are in the project. As a result, this view is useful for adding files to the project.

To view files as a list instead of a tree, in theLayoutfield at the top right of theFilesview, selectList

There are several ways to find files and folders in projects:

  • To search for particular files or file types by name, in any file view, type in the search box or click theFilterbutton. For example, in the search field, enter the texttimestable。The project returns all files and folders that contain the wordtimestable。Click theto clear the search.

  • To search the content of files, go to theProjecttab and click theSearchbutton. Enter a value in the search field and clickEnter。例如,输入单词tests。The project displays all files and folders that contain the wordtests。Click theto clear the search.

  • To change how files are grouped or sorted, and to customize the columns, click the actions按钮并从可用选项中选择。

Open and Run Frequently Used Files

You can use shortcuts to make files easier to find in a large project. View and run shortcuts on theProject Shortcuts标签。You can organize the shortcuts into groups.

The Times Table App project contains several shortcuts, including a shortcut to open the project requirements, and another to run all the tests in the project. The shortcuts make these tasks easier for users of the project.

To perform an action, on theProject Shortcutstab, click the associated shortcut. For example, to open project requirements, clickDocumentation > Requirements。To run tests, clickTest > Run All Tests

To create a new shortcut, select theFilesview, right-click a file, and selectCreate Shortcut

Add Folder to Project

Create a new folder and add it to the project path. Adding a project folder to the project path ensures that all users of the project can access the files within it.

  1. Select theFilesview.

  2. Right-click in white space and then selectNew > Folder。Enter a name for the folder. The folder is automatically added to the project.

  3. Right-click the new folder and select项目路径>添加到项目路径(包括Subfolders)

Review Changes in Modified Files

Open files, make changes, and review the changes.

  1. Select theFilesview. View folders using the tree layout, and then expand theutilitiesfolder.

  2. Right-clicksource/timesTableGame.mand selectOpen

  3. Make a change in the Editor, such as adding a comment, and save the file.

  4. In theFilesview, select theModified (number of files)标签。After editing the file, you seeModified (2)。The file you changed appears in the list.

  5. To review changes, right-clicksource/timesTableGame.min theModifiedfiles view and selectCompare>Compare to Ancestor。The MATLAB Comparison Tool opens a report comparing the modified version of the file in your sandbox to its ancestor stored in version control. The comparison report type can differ depending on the file you select. If you select a Simulink® model to compare, this command runs a Simulink model comparison.

* Note - When you open the Times Table App example project, the project shows a modified file in the资源folder. This is a side effect of opening the example project. When editing files in your own projects, only changes that affect file metadata, such as adding a label to a file, create modified files in the资源folder.

Analyze Dependencies

To check that all required files are in the project, run a file dependency analysis on the modified files.

  1. On theProjecttab, clickDependency Analyzer

  2. The dependency graph displays the structure of all analyzed dependencies in the project. The right pane lists required toolboxes and any problem files. Observe that there are no problems files listed.

Now, remove one of the required files. Select the projectFilesview, right click thesource/timesTableGame.mfile, and selectRemove from Project。ClickRemovein the Remove from Project dialog box.

The Dependency Analyzer automatically updates the graph and theProblemssection in thePropertiespane.

Check again for problems.

  1. In the Dependency Analyzer, in thePropertiespane, point to the problem message,Not in project, underProblemsand click the magnifying glass。图表更新以突出显示问题文件,timesTableGame.m.

  2. To view the dependencies of the problem file, in theImpact Analysissection, clickAll Dependencies

Now that you have seen the problem, fix it by returning the missing file to the project. Right-click the file and selectAdd to Project。下次运行依赖关系分析时,该文件不会以问题文件的形式出现。

After running a dependency analysis, to investigate the dependencies of modified files, perform an impact analysis.

  1. In theViewssection, clickSource Control。The graph colors the files by source control status.

  2. Select the modified files in the graph or in theFile List

  3. To view the dependencies of the modified files, in theImpact Analysissection, clickAll Dependencies

Run Project Integrity Checks

To make sure that your changes are ready to commit, check your project. On theProjecttab, clickRun Checksto run the project integrity checks. The checks look for missing files, files to add to source control or retrieve from source control, and other issues. The Checks dialog box offers automatic fixes to problems found, when possible. When you click aDetailsbutton in the Checks dialog box, you can view recommended actions and decide whether to make the changes.

犯罪Modified Files

修改后文件和满意the results of the checks, you can commit your changes to the source control repository.

  1. In the Files view, select theModified (number of files)标签。您更改的文件显示在列表中。

  2. To commit your changes to source control, on theProjecttab, in theSource Controlsection, click犯罪

  3. Enter a comment for your submission, and clickSubmit。Watch the messages in the status bar as the source control commits your changes. In Git, you can have both local and remote repositories. These instructions commit to the local repository. To commit to the remote repository, in theSource Controlsection, clickPull

View Project and Source Control Information

To view and edit project details, on theProjecttab, in theEnvironmentsection, clickDetails。View and edit project details such as the name, description, project root, startup folder, and location of folders containing generated files.

To view details about the source control integration and repository location, on theProjecttab, in theSource Controlsection, clickGit Details。The Times Table App example project uses Git source control.

Close the Project

Click theat the top right corner of the project window to close the project.

proj = currentProject; close(proj);

相关话题