can a function be made to be called from any directory?
Ältere Kommentare anzeigen
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 Kommentar
Stephen23
am 24 Mär. 2025
"can a function be made to be called from any directory?"
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 24 Mär. 2025
0 Stimmen
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 Kommentar
hxen
am 24 Mär. 2025
Kategorien
Mehr zu Search Path finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!