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:
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:
- 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:
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.