how to test if toolbox exists?
77 ビュー (過去 30 日間)
古いコメントを表示
I am writings some code that I wish to distribute open source. Within my code, I'd like to check if the end-users have fsolve in their installation and if not, use fzero. I'd rather the end-user not get ugly messages about functions not existing, and beginners will be so confused about what to do to fix the error, or they will hate Matlab. Is there a way that this can be implemented easily?
0 件のコメント
回答 (4 件)
Walter Roberson
2012 年 5 月 3 日
11 件のコメント
Walter Roberson
2022 年 8 月 15 日
Note that 'Neural_Network_Toolbox' is the old name for Deep Learning Toolbox, and the old name is still used internally for license capabilities.
If you want to find out whether Deep Learning Toolbox is installed, then
ver('nnet')
Again, 'nnet' is an internal name for this purpose, derived from the old marketing name Neural Network Toolbox
If ver shows the toolbox but license test does not show it, then go to the command window and Help -> Licensing -> Update Current Licenses... to make sure the license is up to date (in case features got added to the license after the file was downloaded.)
Image Analyst
2012 年 5 月 3 日
Here's the code I use:
% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end
You'll need to adapt it for any toolboxes that you want to check.
0 件のコメント
Geoff
2012 年 5 月 3 日
Try this:
v = ver;
has_fsolve = any(strcmp(cellstr(char(v.Name)), 'Optimization Toolbox'));
Or more specifically:
has_fsolve = ~isempty(which('fsolve'));
2 件のコメント
Geoff
2012 年 5 月 4 日
Oh, thanks =) I get a bit baffled sometimes when things look like the right type but return multiple answers. That's a much nicer syntax.
Reza Ahmadzadeh
2015 年 6 月 29 日
You can use the existing function in FileExchange called isToolboxAvailable . The usage is as follows:
result = isToolboxAvailable('image processing toolbox','error');
1 件のコメント
Kjartan Andersen
2016 年 2 月 27 日
Not a good idea to have an external functionality to check for dependencies. What if the user doesn't have this tool?
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!