MATLAB Answers

Initial working folder not working?

183 views (last 30 days)
Martin Guzman
Martin Guzman on 20 Apr 2017
So I want to have a folder that always opens up when I start up MATLAB. I went on Preferences>General and I've tried both "Last working folder.." and a specific folder, but it still opens up some random folder.
There has to be a way to fix this, its bugging me way to much. R2017a - Version I'm running
Qingyu on 20 Mar 2020
Little Fox and diwakar's answer works, Thanks!

Sign in to comment.

Answers (6)

Steven Lord
Steven Lord on 15 May 2017
If you're on Windows and are launching MATLAB using a shortcut, right-click the shortcut you use to start MATLAB and open the Properties of that shortcut. Check the "Start in" line on the Shortcut tab. It should be blank. If it is not blank, it should contain the name of the "random folder" in which MATLAB starts.
If that shortcut has a blank "Start in" line, or if you're not launching MATLAB from a shortcut, check if you have a startup.m in your current directory that includes a cd call, or if your system administrator has added a call to cd to matlabrc.

Kevin on 27 Jun 2018
I, too, experienced the same problems despite changing the appropriate settings in Preferences for MATLAB R2018a on Ubuntu 18.04. The problem was fixed for me by using the -useStartupFolderPref flag as mentioned above. For future reference, my working Ubuntu .desktop launcher file now reads:
[Desktop Entry]
Name=MATLAB R2018a
Comment=Start MATLAB
Exec=matlab -desktop -useStartupFolderPref
StartupWMClass=MATLAB R2018a - academic use
The "StartupWMClass" line fixes the potential presence of many instances of MATLAB open in the dock.
Julio Cesar Gonzalez-saenz
In Ubuntu 20.04, for matlab release 2021a, I have to add the window class: com-mathworks-util-PostVMInit.
Otherwise, the launcher did not show the .desktop.

Sign in to comment.

ES on 20 Apr 2017
For windows only:
How do you open up matlab? Using a shortcut? right click the shortcut to see the properties "Start In:"
John Harris
John Harris on 26 Mar 2018
I did this to fix my taskbar shortcut:
  • closed matlab
  • unpinned matlab from my taskbar
  • put an icon on the desktop and cleared the 'start in' folder
  • drug the icon to the taskbar

Sign in to comment.

robobobeng on 26 May 2017
Well, clearing the content of the "Start in" line fixed the problem for me. (version R2017a as well). Thank you very much Steven Lord!

Bora Eryilmaz
Bora Eryilmaz on 12 Jun 2017
The Initial Working Folder preferences on the Preferences > General panel will only be active when you start MATLAB:
  • From a (Windows) shortcut with no "Start in" folder specified in the shortcut properties dialog. Otherwise, the folder specified in "Start in" takes precedence.
  • From a terminal window with the -userStartupFolderPref flag
In all other cases, MATLAB startup folder will behave as in previous releases.
  1 Comment
SB on 4 Nov 2020
Typo: It should say -useStartupFolderPref

Sign in to comment.

Moritz Schappler
Moritz Schappler on 22 Mar 2018
Since the previous answers focus on Windows: For Matlab R2017b on Ubuntu 16.04, I was able to fix the problem with the command `userpath` in Matlab.

Community Treasure Hunt

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

Start Hunting!