Test if toolbox is installed

225 views (last 30 days)
I need to test if the program user has the "Statistics and Machine Learning Toolbox" installed. I'm use to testing licenses using: license('test', 'Simulink') as an example. When I use license('test', 'Statistics_and_Machine_Learning_Toolbox'), however, I receive the following error:
Error using license Feature name must be less than 28 characters.
Error is pretty straightforward, but I'm wondering if anyone has a workaround or another way to test for toolbox installation?
Thanks

Accepted Answer

Sean de Wolski
Sean de Wolski on 5 Jun 2015
Edited: Sean de Wolski on 26 Jul 2018
The license name is usually one or two words , so for stats, it will still be Statistics_Toolbox
license('test','statistics_toolbox')
  7 Comments
Chad Greene
Chad Greene on 15 Feb 2019
Yeah, where is the complete list of features we can test for with the license function? There's only a partial list in the docs, so we're left shooting in the dark for things like the 'mapping_toolbox' .
Making matters worse, if you get the name wrong, the license function will implicitly tell you that there is a toolbox by that incorrect name, but you just don't have that toolbox. For example, I have the Mapping Toolbox, yet if I type this:
license('test','mapping_toolbox')
ans =
0
I'm left to believe I don't have the Mapping Toolbox. Implementing a check of all possible toolbox names might be logistically difficult, but providing a current list of all possible license names in the documentation would be very easy.
Walter Roberson
Walter Roberson on 15 Feb 2019
Chad, see my table at
I updated it today.
I do not have information on all of the toolboxes, and there are a few where I am not certain on the ver() code as I do not have them installed to test with.

Sign in to comment.

More Answers (3)

Christian Odenthal
Christian Odenthal on 3 Dec 2020
Edited: Christian Odenthal on 3 Dec 2020
Had the same problem and came to this solution:
contains(struct2array(ver), 'Statistics and Machine Learning Toolbox')
and for older matlab versions this works as well:
any(any(contains(struct2cell(ver), 'Statistics and Machine Learning Toolbox')))

Demis John
Demis John on 26 Jul 2018
Hello, The answer here only gives us a command for finding out if a license is in use - not if the package is installed.
You actually need to check both the license AND installation, to catch such errors. It turns out that you can check for a license, get a "True" answer, but your program will still fail because the Toolbox isn't actually installed!
How can you _ programatically_ check if the toolbox is installed?
  2 Comments
Steven Lord
Steven Lord on 26 Jul 2018
Use the ver function.
Chad Greene
Chad Greene on 15 Feb 2019
Using ver still is not a programmatic solution. See, entering the full name doesn't work:
>> ver('Statistics and Machine Learning Toolbox')
-----------------------------------------------------------------------------------------------------
MATLAB Version: #####
MATLAB License Number: #########
Operating System: #######
-----------------------------------------------------------------------------------------------------
Warning: No properly formatted Contents.m file was found for 'Statistics and Machine Learning Toolbox'.
> In ver (line 58)
...and entering the short name doesn't do anything either:
>> ver('image_toolbox')
-----------------------------------------------------------------------------------------------------
MATLAB Version: #####
MATLAB License Number: #########
Operating System: #######
-----------------------------------------------------------------------------------------------------
Warning: No properly formatted Contents.m file was found for 'image_toolbox'.
> In ver (line 58)

Sign in to comment.


Walter Roberson
Walter Roberson on 2 Feb 2022
See the interesting code by @Julian Hapke at https://www.mathworks.com/matlabcentral/answers/377731-how-do-features-from-license-correspond-to-names-from-ver#answer_430148 which uses MATLAB code to find the names, and so should be independent of installation directories.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!