MATLAB: How to start MATLAB in terminal (Mac) with the folder where I start it as the initial working folder

initial working foldermacMATLABstart-upterminal

When I start Matlab by typing matlab in the terminal on MacBook, the current folder is the last working folder from the previous session. In the Preferences-General, 'the last working folder from the previous MATLAB session' is checked. There is an option there to specify the initial folder, but I don't know how to specify the folder where Matlab is started. Is it possible?
In .bachrc, I have the following:
export MATLAB_USE_USERWORK=1
alias matlab='/Applications/MATLAB_R2017a.app/Contents/MacOS/MATLAB'
Is there any way to define the initial working folder to be the folder where Matlab is started from the terminal?

Best Answer

Use the -sd or -useStartupFolderPref options. https://www.mathworks.com/help/matlab/ref/matlabmac.html