can a function be made to be called from any directory?
Afficher commentaires plus anciens
I have custom functions that I would like to be called independent of the directory it is called. Can this be done, like for the MATLAB functions? Can someone steer me to an example or page to learn about this if it is possible?
1 commentaire
Stephen23
le 24 Mar 2025
"can a function be made to be called from any directory?"
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 24 Mar 2025
0 votes
If you are referring to custom functions that are to be called no matter which directory you call them from, then the answer is "That cannot be done" -- not unless you "import" the name.
The function call precedence order is described at https://www.mathworks.com/help/matlab/matlab_prog/function-precedence-order.html
Object functions are only #7, and Class constructors are only #8, and Functions elsewhere on the path, are only #11 -- which is lowest precedence.
So no matter what name you give to the function or how you declare the function, there are cases where other functions with the same name will have higher priority... unless you "import" the name.
1 commentaire
hxen
le 24 Mar 2025
Catégories
En savoir plus sur Search Path dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!