How do I automatically add folders to the MATLAB path on startup when using batch mode?
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 27 Juin 2009
Modifié(e) : MathWorks Support Team
le 14 Sep 2023
I would like to automatically add folders to the MATLAB path on startup when using batch mode.
Réponse acceptée
MathWorks Support Team
le 14 Sep 2023
Modifié(e) : MathWorks Support Team
le 14 Sep 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 commentaire
Rub Ron
le 3 Sep 2020
matlab -r addpath('$my_path/folderName')
can I use this if my_path is a variable ifrom linux bash?
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!