add function to toolbox path
9 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Konark Kelaiya
2016-8-5
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Search Path 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!