Main Content

MATLAB Startup Folder

Default Startup Folder

By default, MATLAB® sets the startup folder based on the way you start MATLAB. To identify the startup folder, type pwd at the command line immediately after starting MATLAB and before typing any other commands. You can change the startup folder using the General Preferences options in the Preferences Window. For convenience, make this folder a folder that you frequently use.

Note

If a startup.m file changes the current folder, then this value overrides the initial working folder value. Do not add cd statements to startup.m. For more information about user-defined options, see startup.

Default Folder on Windows Platforms

How You Start MATLABStartup Folder

Double-click the MATLAB icon on your Windows® desktop or in the Start menu

Last working folder from the previous MATLAB session or the custom path specified in the Initial working folder preference. The Initial working folder preference is located in the General Preferences page of the Preferences Window.

From a Windows system prompt

Folder in which you run the matlab command (To use the folder specified by the Initial working folder preference, use the -useStartupFolderPref startup option.)

From the MATLAB command prompt

Folder in which you run the !matlab command

Double-click a file type associated with MATLAB

Folder containing the file

Double-click the matlab.exe executable file from Windows Explorer Tool

Last working folder from the previous MATLAB session or the custom path specified in the Initial working folder preference

For more information, see Start MATLAB on Windows Platforms.

If you start MATLAB by double-clicking the MATLAB shortcut icon and the startup folder is set to an unexpected location, follow these steps to ensure that the Start in field in the MATLAB shortcut icon is empty:

  1. Right-click the shortcut icon for MATLAB and select Properties from the context menu. The Properties dialog box for MATLAB opens to the Shortcut pane.

  2. If the Start in field contains text, clear the text.

  3. Click OK and try starting MATLAB again.

Default Folder on macOS Platforms

How You Start MATLABStartup Folder

Double-click the MATLAB application

Last working folder from the previous MATLAB session or the custom path specified in the Initial working folder preference, located in the General Preferences page of the Preferences Window

Start MATLAB from a Terminal window

Folder in which you run the matlab command

For more information, see Start MATLAB on macOS Platforms.

Default Folder on Linux Platforms

On Linux® platforms, the default startup folder is the folder from which you started MATLAB.

For more information, see Start MATLAB on Linux Platforms.

Change Startup Folder

Starting in R2014b, you can change the startup folder using the General Preferences options in the Preferences Window. On the Home tab, in the Environment section, click Preferences. Select MATLAB > General. Choose an option for the Initial working folder preference.

Alternatively on Windows platforms, specify the initial working folder in the MATLAB shortcut icon. For more information, see Select MATLAB Icon.

userpath as Initial Working Folder

Using userpath as the Initial working folder value offers these benefits.

  • You can store the MATLAB files you work with in one folder, such as Documents/MATLAB.

  • You can always run your files because MATLAB automatically adds the userpath folder to the top of the search path.

  • The first time you run a new version of MATLAB, the software automatically creates the userpath folder if it does not exist.

  • When you upgrade to a newer version of MATLAB, the software automatically continues to use the same startup folder and your existing files.

  • The default userpath uses the benefits provided by the standard location in the Windows and macOS environments for storing personal files. Files in the Documents/MATLAB folder are available to you when you use other machines. Each user has an individual Documents/MATLAB folder. Other users, even those using your machine, cannot access files in your Documents/MATLAB folder.

See Also

|

Related Topics