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

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?

 Respuesta aceptada

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

3 comentarios

Thank you so much for your advice. I tried it both:
matlab -sd
matlab -useStartupFolderPref
but then the startup folder is now
/Users/username/Documents/MATLAB
not the folder where matlab is started. I've been looking for some hints in matlab help and Google search, but haven't been able to figure this out...
alias matlab='/Applications/MATLAB_R2017a.app/Contents/MacOS/MATLAB -sd $(pwd)'
It works great! Thank you so much for your help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Productos

Preguntada:

HN
el 20 de En. de 2018

Comentada:

HN
el 20 de En. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by