Why is my initial working folder not being set properly in MATLAB R2020b?

17 次查看(过去 30 天)
I am trying to change my initial working folder in MATLAB R2020b. I tried to change the initial working folder in Preferences by following the steps outlined in the following documentation link: 
However, MATLAB still opens to a different directory. 
I then tried to remove the current initial working directory using "Set Path" in the Home -> Environments tab in the Toolstrip, and by using the function "rmpath". Still, MATLAB opens to the wrong directory. How can I point MATLAB to my desired initial working directory?

采纳的回答

MathWorks Support Team
This could be because at startup MATLAB is adding a different directory to the search path than the one you have specified in your Preferences.
One reason for this could be that the function "userpath" was previously used to add the incorrect initial working directory to the search path at startup.
  • Check to see if there is a folder being added to the search path at startup by typing the command:
>> userpath
in the Command Window.
  • If the output is non-empty, then this means that the directory returned by "userpath" is being added to the MATLAB search path at startup.
  • To clear it for all future sessions of MATLAB, execute the command:
>> userpath('clear')
  • Restart MATLAB and check to see if MATLAB opens to the correct initial working directory. 
If MATLAB still opens to the incorrect directory, then this could be because the path to the incorrect initial working directory is added in a "startup.m" file. These "startup.m" files can perform different tasks, such as including additional paths to the search path and changing the working directory.
  • Check to see if there is a "startup.m" file by executing the command:
>> which startup.m
in the Command Window.
  • If there is a "startup.m" file, open it in the MATLAB Editor.
  • Search "startup.m" to see if "addpath" or "path" is used to add the incorrect initial working directory to the startup search path.
  • If so, comment out the relevant line(s) and save the "startup.m" file. 
  • Restart MATLAB and check to see if MATLAB opens to the correct initial working directory. 

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by