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
.
How You Start MATLAB | Startup 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 | Folder in which you run the |
From the MATLAB command prompt | Folder in which you run the
|
Double-click a file type associated with MATLAB | Folder containing the file |
Double-click the | 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.
How You Start MATLAB | Startup 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 | Folder in which you run the |
For more information, see Start MATLAB on macOS 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.
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 FolderUsing 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.