Conventional / "best practices" location for personal functions
Show older comments
Is there a conventional / standard / "best practices" location for parking self-developed functions, such that they are globally available from the command prompt (i.e. independent of current working directory)? I initially thought about $MATLABROOT/toolbox/local, but that contains exclusively TMW-provided scripts and text files. Moreover, as explained by John D'Errico in this old thread, there are potential issues with path caching at startup for anything placed inside $MATLABROOT.
(To be clear, I'm interested in where, rather than how. Either path or pathtool can be used to do the latter.)
5 Comments
dpb
on 21 May 2020
I have a WORK directory for current transient day-to-day stuff and dedicated subdirectories for specific projects.
The general things that are useful everywhere are in \UTILS which I put at the head of the MATLABPATH.
AMM
on 21 May 2020
dpb
on 21 May 2020
Precisely.
Like many newbies, once upon a time I would do things like customize a builtin function or add a routine in a distribution location -- didn't take but a couple of times of having to recreate the environment after a new release to realize the advice to not do that was wise...
@AMM: you should not add/remove/edit files within any application's installation directories. This is not just because of function caching issues (i.e. something specific to MATLAB), but because it is inherently a bad idea to alter anything in the installation directory of any application, even in locations that you think are benign, e.g. MATLAB's toolboxes.
https://www.mathworks.com/matlabcentral/answers/222839-how-to-use-functions-from-private-directories
There be dragons!
AMM
on 3 Jun 2020
Accepted Answer
More Answers (0)
Categories
Find more on Introduction to Installation and Licensing 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!