add function to toolbox path

6 次查看(过去 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

采纳的回答

Konark Kelaiya
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)
  1 个评论
Sina Shojaei
Sina Shojaei 2016-8-8
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by