How can I avoid the "change folder / add to path" window when running a script?
63 views (last 30 days)
Show older comments
This window pops up every time I run a new script, and I always click "add to path." I know how to use the addpath or cd functions within my script to make this go away the next time I run the script, but I still think I've clicked this button a couple thousand times in my life. Is there a way I can avoid it?
Please note that I'm always running scripts from various new project folders, so adding certian folders to matlab's startup routine is not a future-proof option for me.
thank you!

1 Comment
Adam Danz
on 27 Apr 2019
Edited: Adam Danz
on 27 Apr 2019
In response to your edited question, are you saying that the location of your files is completely unpredictable? That sounds like more of a organizational problem. Usually files are stored in subdirectories within a main directory, or if you're using a network within a couple main directories. With that organization, you can simply add all of the paths that lead to all of your needed files during startup.
You mentioned you add the paths when you're prompted, so I assume you know where the files are. What's preventing you from adding those paths to the startup file?
Answers (1)
Adam Danz
on 26 Apr 2019
Edited: Adam Danz
on 26 Apr 2019
"At startup, MATLAB automatically executes the matlabrc.m file and startup.m, if it exists on the MATLAB search path. The file matlabrc.m, which is in the matlabroot/toolbox/localfolder, is reserved for use by MathWorks® and by system administrators on multiuser systems."
In your startup.m file, add all necessary paths to run your scripts, functions, and other files that matlab needs access to.
Next time (and every time) you start matlab, the paths will be added automatically.
3 Comments
Adam Danz
on 26 Apr 2019
An additional recommendation is to add a 'favorite' command that you can quickly run every time you access a network or remote computer after startup has already run.
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!