Effacer les filtres
Effacer les filtres

add function to toolbox path

7 vues (au cours des 30 derniers jours)
Sina Shojaei
Sina Shojaei le 5 Août 2016
Commenté : Sina Shojaei le 8 Août 2016
Hello All, I've added a function to the installation path of the global optimization toolbox matlabroot\ toolbox\globaloptim\globaloptim but I don't seem to have acess to it. so if I go
> edit myFunc
matlab says function does not exist, do I want to create it?
I can however edit other functions in the same directory so for example this works fine
> edit ga
Have tried adding the folder to path but it didn't help. The function needs to be in that folder because its using some other default functions that are private to that folder
Any idea would be appreciated
Sina

Réponse acceptée

Konark Kelaiya
Konark Kelaiya le 5 Août 2016
Well Private functions are meant for the purpose that it won't be seen from any other directory or functions kept other than its parent directory.
Now When you have created your own function and kept at MATLAB Toolbox path , it is not good idea,because that function is not visible to MATLAB due to licensing management. That's why you will get "function don't exist" error.
Any other MATLAB in-built function within that toolbox will not have issue.
To this below can be solution
1. Do Make a copies of private functions and create directory on local drive lets say D:\ then add parent directory of that private function to MATLAB ADDPATH. In this way, you will get warning but functions will run.
Warning occurs because MATLAB will have two paths for same private functions. To overcome this , you can rename private functions as your wish and use.
2. Make Local functions in your "myfunction" function and use outside matlab toolbox path while adding directory to matlab search path or making it current working directory.
3. Another quick-and-dirty solution is change directory to the private directory, and switch back at the end. (Not recommend)
  1 commentaire
Sina Shojaei
Sina Shojaei le 8 Août 2016
thanks, I've created local copies and renamed the private functions. Thought it might be license issue but then can't see why they want to restrict this. Cheers

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Search Path dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by