I have been searching an entire afternoon and have found no solution to call in matlab a function by specifying its path and not adding its directory to the path.
This question is quite similar to Is it possible to call a function that is not in the path in MATLAB?, but in my case, I do not want to call a built-in function, but just a normal function as defined in an m-file.
I think handles might be a solution (because apparently they can refer to functions not on the path), but I again found no way to create a handle without cd
-ing to the directory, creating it there and the cd
-ing back. Trying to 'explore' what a function handle object is and how to make one with a reference to a specific function not on the path has led me nowhere.
So the solution might come from two angles:
1) You know how to create a handle for an m-file in a specific directory.
2) You know a way to call a function not on the matlab path.
EDIT: I have just discovered the function functions(myhandle)
which actually lets you see the filepath to which the handle is referring. But still no way to modify it though...
feval
command, which is the most natural place for this capability, specifically excludes specifying the directory. "Thefname
parameter must be a simple function name; it cannot contain path information." – Seigneuryremovepath(...);function();addpath(...)
and the like... This breaks if 2 users do it at the same time. So the easiest solution would be to be able to call a specific function directly without worrying about the path – Mueller