The files and folders of the BEV model are managed by MATLAB project.
With MATLAB Project, you can manage MATLAB paths as project paths relative to the project root folder, which makes it easy to open or run scripts and models anywhere in the project.
Tip: Avoid using folder paths in your scripts and models. Using MATLAB project makes it possible to refer to models and scripts without folder paths, and it guarantees that models and scripts continue to work after moving them around within the project.
MATLAB Project analyzes dependecy relationships among files registered in the project and helps you work with them. For example, when you change the name of a MATLAB function in the Project window (not in the Current Folder window), the project finds locations in other files where the function is called and automatically updates them.
You can find which files depend on which other files. In the Project window, right-click a file or folder in the project tree, and select Find Dependencies. It opens Dependency Analyzer showing the graph of file dependencies.
From the Dependency Analyzer, you can export a subset of files and folders to a separate project archive file or a zip file. To do so, first find the dependencies as described above, then select Export in the Analyzer toolstrip, and select Package As Archive.
MATLAB Project supports source control tools such as Git. For details, see the documentation about Source Control Integration.
If you downloaded a zip file of a project from File Exchange or GitHub, it does not include git data. You can add git to the project locally in your machine by following the steps below. (Using a remote git service such as GitHub or GitLab needs further steps, which you can do later.) Make sure to complete all these steps before making any changes to the project. For more information about using git in MATLAB, see Use Git in MATLAB. For more information about using source control with projects, see Use Source Control with Projects.
- Open the project in MATLAB.
- In the Project toolstrip, click Use Source Control.
- Click Add Project to Source Control....
- Click Convert.
This creates the
.git
folder at the project root folder. - Click Open Project. Then Git column appears in the project window and the Current Folder window.
- In the Project toolstrip, click Commit. This opens the Enter a Commit dialog.
- Enter a comment such as "Initial commit." and click Submit.
At this point, the project must have the following states, and you are good to go to make changes to the project.
- In the Project toolstrip, Commit button is disabled.
- All the files are not modified, which is indicated as Modified (0) right above the Project folder tree area.
Click Branches button in the Project toolstrip to see commit history or create/switch/delete a branch.
Notes on cloud storage
For folders managed by git, it is safe to avoid using a cloud service. Switching a branch locally in git is fast, even if it involves many changes in the folder structures and file contents. On the other hand, cloud storage services tend to be slow because it involves file transfer over the network. Thus, switching git branches can cause synchronization issue for the cloud service, which may corrupt the state of some folders.
For your day-to-day development activities in a project with local git, take the following steps after you edit your files and folders.
- In the Project toolstrip, in the Project tab, click Check Project and make sure no issue is identified.
- Click Commit. This opens the Enter a Comment dialog.
- Enter a comment and click Submit.
Fetch, Push, Pull, and Remote buttons in the Project tab work with a remote git service, and you need an account for the remote service site (such as a GitHub account for github.com). For more information about creating an account for a git service, visit the respective git service website.
As an example, if you have an account at github.com, create an empty repository at GitHub, and set the repository URL from Remote button in the Project tab. When you want to upload the changes in your local repository to the remote repository, first click Check Project and make sure the project is in good shape. Second, click Commit and make sure you have Modified (0). And third, click Push to upload. Push can trigger authentication to access GitHub. For a streamlined user experience, you might want to use GitHub Desktop to push.
Go to README at the project top folder.
Copyright 2022-2024 The MathWorks, Inc.