MATLAB Answers

Initial working folder not working?

157 views (last 30 days)
Martin Guzman
Martin Guzman on 20 Apr 2017
Commented: Thien-Minh Nguyen on 30 May 2020
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

  6 Comments

Show 3 older comments
Little Fox
Little Fox on 2 Aug 2017
To fix it, right click your Matlab icon, select properties->shortcut, in "start in", delete the default folder. Now the preference setting should work.
diwakar pyakurel
diwakar pyakurel on 18 Apr 2018
To fix it, right click your Matlab icon, select properties->shortcut, in "start in", delete the default folder. Now the preference setting should work. ok it works.
Qingyu
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.

  0 Comments

Sign in to comment.


Kevin
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]
Type=Application
Icon=/usr/share/icons/matlab.png
Name=MATLAB R2018a
Comment=Start MATLAB
Exec=matlab -desktop -useStartupFolderPref
Categories=Development;
StartupNotify=true
StartupWMClass=MATLAB R2018a - academic use
The "StartupWMClass" line fixes the potential presence of many instances of MATLAB open in the dock.

  2 Comments

Jake Moss
Jake Moss on 29 Apr 2020
I have been searching for ages for a solution, this is the only thing that has worked.
Thien-Minh Nguyen
Thien-Minh Nguyen on 30 May 2020
This solves both the pains in one go.
To newbies like me, this is what you do on unbuntu 18.04:
After installing Matlab, in the Command Window, input
userpath('/your/preferred/startup/directory')
Then open file /usr/share/applications/matlab.desktop (or create a new one) and change its content to that in Kevin's comment above. You can change R2018a to your release version.
The app can now start in your preferred folder, and all instanaces are grouped under the same launcher icon.

Sign in to comment.


ES
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:"

  3 Comments

Martin Guzman
Martin Guzman on 20 Apr 2017
I open MATLAB via the taskbar. Is there a way to set this for the taskbar icon?
At my school, this runs just fine but on my student version at home, it doesn't seem to be working.
Sndn_Shr
Sndn_Shr on 7 Nov 2017
Same is available for taskbar. When you right-click on the icon in taskbar, Matlab and unpin options show in a menu right? There, right click again on Matlab and go to properties.
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
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!

  0 Comments

Sign in to comment.


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.

  0 Comments

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.

  0 Comments

Sign in to comment.