Automate Startup Tasks
In a project, startup files help you set up the environment for your project.
Startup files are automatically run (.m
and .p
files), loaded (.mat
files), and opened (Simulink® models) when you open the project.
Note
Startup scripts can have any name. You do not need to use
startup.m
.
You can use a file named startup.m
on the MATLAB® path which runs when you start MATLAB. If your startup.m
file calls the project with
currentProject
, an error appears because no project is loaded yet. To
avoid the error, rename startup.m
and use it as a project startup file
instead.
Configure an existing file to run when you open your project.
Right-click the file and select Run at Startup.
Alternatively, on the Project tab, click Startup Shutdown. In the Manage Project Startup and Shutdown dialog box, you can add and remove startup and shutdown files. If execution order is important, change the order using the arrow buttons.
In the files view, the Status column displays an icon and tooltip indicating the file will run at startup.
Note
Startup file settings are included when you commit modified files to source control. Any startup tasks you create run for all other project users.
To stop a file running at startup, change back by right-clicking it and selecting Remove from Startup.
On the Manage Project Startup and Shutdown dialog box, use the check boxes to specify environment options:
Start Simulink before this project starts–This option starts Simulink when you open the project.
Refresh Simulink customizations– This option runs
sl_customization
files on project startup and shutdown.
When you open the project, the startup files run. Also, the current working folder changes to the project startup folder. If you want to set the startup folder, on the Project tab, click Details and edit the Start Up folder. See Specify Project Details, Startup Folder, and Derived Files Folders.
You can create new startup and shutdown files interactively in the project or at the
command line. For details, see addStartupFile
.
Related Examples
- Specify Project Path
- Automate Shutdown Tasks
- Create Shortcuts to Frequent Tasks
- Use Shortcuts to Find and Run Frequent Tasks