Main Content


User-defined startup script for MATLAB




startup executes user-specified commands when starting MATLAB®. MATLAB executes any file on the search path named startup that has an executable file extension. Examples of an executable file extension are .m, .mlx, and .mlapp.

Create a startup.m file in the userpath folder, which is on the MATLAB search path. Add commands you want executed at startup. For example, your code might include physical constants, defaults for graphics properties, engineering conversion factors, or anything else you want predefined in your workspace.


collapse all

Open startup.m in your userpath folder.


Set the default colormap to autumn. Enter this statement into the file.

set(0, 'DefaultFigureColormap', autumn(64))

Save and close the file.

Restart MATLAB and display a plot.


The default colormap value is autumn.

Restore the default colormap value. Remove the set statement for DefaultFigureColormap.


Save and close the file. The next time you start MATLAB, the default colormap value is the MATLAB default.

Locate the startup.m file.

which startup


  • To specify the current folder in MATLAB when it starts, set the Initial working folder preference located in the General Preferences page of the Preferences.


At startup, MATLAB automatically executes the matlabrc function and, if it exists on the MATLAB search path, startup. The matlabrc file, which is in the matlabroot/toolbox/local folder, is reserved for use by MathWorks® and by system administrators on multiuser systems.

Version History

Introduced before R2006a