Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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 panel. 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, described in General Preferences.

From a Windows system prompt

The 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

The folder in which you run the !matlab command.

Double-click a file type associated with MATLAB

The 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.

Default Folder on Mac 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 described in General Preferences.

Start MATLAB from a Terminal window

The MATLAB installation folder.

For more information, see Start MATLAB on Mac 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 panel. 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 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, MATLAB automatically creates the userpath folder if it does not exist.

  • When you upgrade to a newer version of MATLAB, MATLAB 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 Mac 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 Examples

More About

Was this topic helpful?