can a function be made to be called from any directory?
Mostra commenti meno recenti
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 Commento
Stephen23
il 24 Mar 2025
"can a function be made to be called from any directory?"
Risposta accettata
Più risposte (1)
Walter Roberson
il 24 Mar 2025
0 voti
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 Commento
hxen
il 24 Mar 2025
Categorie
Scopri di più su Search Path in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!