When I open a MATLAB Project, the contents of the project are automatically added to the MATLAB path. However, when I close this project, the project directory is removed from the MATLAB path. How can I make the project directory persist on the path after closing?
MATLAB: How to keep a MATLAB Project directory on the MATLAB path after closing the project
MATLAB
Related Solutions
Do you want to put project parts in \projectpath\folder1\filesforpart1.m, \projectpath\folder2\filesforpart2.m or would you like to have something like \projectpath\part1\files.m and \otherpath\part2\files.m?
If you thought of the first suggestion then you are able to add these folders to project path and you can commit them to GitHub.
If you thought of the second one, then maybe "Submodules" option could be what you're looking for, but this involves multiple repositories.
You can either create a blank project and add all the files in the project, or create the project directly from a Simulink model.
To create a blank project, you can follow the documentation page:
1. On the MATLAB
Home
tab, click
Simulink
or select
New
>
Simulink Project
.
2. In the Simulink Start Page, select '
Blank Project
'
3. Fill in the project name and Project Folder. Please put the folder where you store all your existing files to the Project Folder
Then you should be able to see the Simulink Project User Interface. You can add the existing files according to this documentation:
4. The project has been created but there will be no files in the project. In order to see all the files in the project folder, select "
All Files View
"
5. Select all the files and folders in the view, right click the files and select "
Add Folder to Project (Including Child Files)
"
6. After adding all the files to the project, you can switch back to the "
Project Files View
"
You can also add folders to Project Path. The folder in project path will be added to MATLAB path when you open the project and will be removed from MATLAB path when you close the project. You can find more information in the following documentation page:
7. To add folders to project path, simply select the folders, right click and select "
Project Path
" and select either "
Add to Project Path
" or "
Add to the Project Path (Including Subfolders)
" depending on your use case.
To create a project from a Simulink Model, you can follow the documentation page here:
1. Open the Simulink model, select "
File
" -> "
Simulink Project
" -> "
Create Project from Model
"
2. Fill the
Project name
and
Project folder
, select the files you would like to be included in the project and click
Create
The project should be created with all selected files included in the project. By default, the folders selected should be already added in the project path.
Best Answer