Why is the initial working folder not opening when I start MATLAB?

I set the "initial working folder" in my MATLAB Preferences so MATLAB will open my preferred folder when I use the shortcut icon. However, when I first open MATLAB on Windows, the initial working folder is not the folder I specified. How do I change the initial working folder folder that MATLAB opens?

 Accepted Answer

If you start MATLAB using a desktop shortcut: 
This behavior may be the result of a preference on the MATLAB shortcut overriding the MATLAB Preferences. Follow the steps below to remove the startup path from the shortcut:
  1. Right-click on the MATLAB shortcut icon
  2. Select "Properties > Shortcut"
  3. Remove the path specified in the "Start in:" field so it is empty
  4. Click "Apply" and "OK"
  5. Open MATLAB by clicking on the desktop icon. The "initial working folder" should now match the MATLAB Preferences
       
Refer to the following documentation page for more information on the MATLAB Startup Folder: 
If you start MATLAB from the command line:
If you are launching MATLAB from the command line instead of a shortcut icon, set a startup flag during launch to preserve the initial working folder preferences as follows:
matlab -useStartupFolderPref
For more information on this startup flag, refer to the following OS-specific documentation pages:
Windows: 
Linux: 
MacOS:
If both methods still open a different folder:
Check for a "startup.m" file that might include a "cd" call or if there is a call to "cd" in "matlabrc".
>> edit startup.m
>> edit matlabrc

More Answers (0)

Categories

Products

Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!