how to test if toolbox exists?
이전 댓글 표시
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?
답변 (4개)
Walter Roberson
2012년 5월 3일
댓글 수: 11
Mohammad Nazrin Jumali
2016년 3월 14일
it says '1', what does it mean?
Walter Roberson
2016년 3월 14일
It means the license does exist.
Farid
2022년 8월 8일
what should I type for deep learning toolbox, please?
Image Analyst
2022년 8월 8일
@Farid, use the line below for Neural_Network_Toolbox to see if you have a license for the Deep Learning Toolbox.
% Check that user has the specified Toolbox installed and licensed.
hasLicenseForToolbox = license('test', 'image_toolbox'); % Check for Image Processing Toolbox.
% hasLicenseForToolbox = license('test', 'Image_Acquisition_Toolbox'); % Check for Image Acquisition Toolbox.
% hasLicenseForToolbox = license('test', 'Statistics_Toolbox'); % Check for Statistics and Machine Learning Toolbox.
% hasLicenseForToolbox = license('test', 'Signal_Toolbox'); % Check for Signal Processing Toolbox.
% hasLicenseForToolbox = license('test', 'Video_and_Image_Blockset'); % Check for Computer Vision System Toolbox.
hasLicenseForToolbox = license('test', 'Neural_Network_Toolbox'); % Check for Deep Learning Toolbox.
Farid
2022년 8월 9일
@Image Analyst Thank you so much. it doesn't answer my question tho. I asked about the deep learning toolbox as it can be seen in >>ver.
Farid
2022년 8월 9일
Image Analyst
2022년 8월 9일
When you asked "what should I type for deep learning toolbox, please?" I assumed you wanted a logical variable that gave true or false for whether or not you had the Deep Learning Toolbox. So that's why I gave you
hasLicenseForToolbox = license('test', 'Neural_Network_Toolbox'); % Check for Deep Learning Toolbox.
It does exactly that, which is what I thought you asked. Not sure why you said it didn't resolve your problem unless "what should I type for deep learning toolbox, please?" means something different than "what can I type to determine if I have a license for the Deep Learning Toolbox?"
@Reza Ahmadzadeh's code depends on a third party function, not a simple, built-in, one-line function call like I gave you. There is no need to use Reza's code (like the comment after it said).
Farid
2022년 8월 15일
@Image Analyst excuse me, I didn't get any notification on your response, It didn't help because eventhough I had the deep learning toolbox installed it returned 0. if it shouldn't, I have non idea what the problem could be.
Thanks
Image Analyst
2022년 8월 15일
Call tech support and tell them it's an installation issue. Or send the results of "ver" to support@mathworks.com
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.)
Farid
2022년 8월 16일
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.
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'));
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?
카테고리
도움말 센터 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!