Reputation: 1092
I have download some libraries for Matlab. Unfortunately one of those libraries has the same name as one in the Matlab toolbox. So, when trying to call that downloaded library, Matlab calls its own. How can I solve this? Is there I way to 'switch' the path for an specific function?
Upvotes: 2
Views: 77
Reputation: 898
You can temporarily add the folder my_files to the search path, run my_function in my_files, then restore the previous search path. To select which library is used first, just add to the top of PATH.
1) Grab your default path
p = path
2 ) Add c:/matlab/myfiles to the TOP of the search path.
addpath('c:/matlab/myfiles')
2) OR Add Folder to End of Search Path
addpath('c:/matlab/myfiles','-end')
Run you code
my_function
Restore Path
path(p)
So to run from libray A:
% Grab default path
p = path
% Search this folder first
addpath('c:/matlab/A')
% Run your code
my_function
%Restore Path
path(p)
If you have the same function names on different libraries you can just define the library first.
for instance:
duration/max(); % uses max from duration toolbox/libary
max(); % uses standard max.
So you could also just rename you library folder name and select which one you want to use.
Upvotes: 3