add function to toolbox path
7 ビュー (過去 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!