How do I automatically add folders to the MATLAB path on startup when using batch mode?
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 27 de Jun. de 2009
Editada: MathWorks Support Team
el 14 de Sept. de 2023
I would like to automatically add folders to the MATLAB path on startup when using batch mode.
Respuesta aceptada
MathWorks Support Team
el 14 de Sept. de 2023
Editada: MathWorks Support Team
el 14 de Sept. de 2023
There are several ways you can add folders to the MATLAB path automatically every time you start MATLAB in batch mode.
Refer to the MATLAB documentation for an overview of general ways to add folders at startup:Add Folders to the MATLAB Search Path at Startup
For options that work well with batch mode, please see below.
NOTE: Starting in R2019b, the '-r' option is no longer recommended for non-interactive use. Use the '-batch' option in non-interactive scripting or command line workflows. Do not use this option with the -r option.
1. Create a file called startup.m in your MATLAB path. This file is executed when MATLAB opens. Inside you can place the ADDPATH commands and any other variables or scripts you wish you execute on start up.
2. You can permanently add them by typing "pathtool" in the MATLAB command prompt or browsing to "File -> Set Path..."
3. If you call MATLAB from a DOS/terminal prompt, you can type:
matlab -r addpath('your_path_here')
4. Create a script in the MATLAB path, for example, 'addme.m', which predefines the folders you wish to add to the MATLAB path. Type this when you load MATLAB:
matlab -r addme
Note that there should be no spaces in your commands after the '-r' parameter. For example; this will correctly calculate 'c' when starting MATLAB:
matlab -r a=1,b=2,c=a/b
while a space between 'c' and the comma will not:
matlab -r a=1,b=2, c=a/b
1 comentario
Rub Ron
el 3 de Sept. de 2020
matlab -r addpath('$my_path/folderName')
can I use this if my_path is a variable ifrom linux bash?
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!