I use a batch script to start Matlab and set the startup directory via the -sd switch.
:: Matlab startup directory
:: Matlab Executable
:: start Matlab with specified startup directory
call "%MATLAB_EXECUTABLE%" -sd "%STARTUP_DIRECTORY%"
I use this procedure because I work with multiple Matlab configurations (Java classpath, Java library path, Matlab path) in each of the startup directories.
I have a setup script which collects all required information and stores the 3 Matlab configuration files (javaclasspath.txt, javalibrarypath.txt, pathdef.m) in the startup directory. To get that directory in the current Matlab session i used the following (dirty but working) code:
But since Matlab 2019a, this line always returns:
I have also tried the userpath command but unfortunately, this always returns the same directory, no matter which directory is specified as startup directory:
Maybe someone has got a solution or workaround for my problem?