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

 採用された回答

Sean de Wolski
Sean de Wolski 2015 年 6 月 5 日
編集済み: Sean de Wolski 2018 年 7 月 26 日

1 投票

The license name is usually one or two words , so for stats, it will still be Statistics_Toolbox
license('test','statistics_toolbox')

7 件のコメント

Cory Shutz
Cory Shutz 2015 年 6 月 5 日
Thanks Sean. I had seen Statistics_toolbox in other scripts but assumed they were two different toolboxes... Should've tried that earlier.
Sean de Wolski
Sean de Wolski 2015 年 6 月 8 日
The Statistics Toolbox was renamed the Statistics and Machine Learning Toolbox in 15a. It's for branding properly, not a change in functionality.
Image Analyst
Image Analyst 2015 年 6 月 8 日
The names to use in license() do not match the actual names. For example license('test', 'image_toolbox') is for the Image Processing Toolbox. But you can't just take the first word of the toolbox. For example what would you put for the Image Acquisition Toolbox? Is there someplace where you can find these names? You cannot even use license('inuse') to show your current licenses despite what the help incorrectly says. Mine says only "matlab" using license('inuse'), despite "ver" showing 6 toolboxes. So, if for example you wanted to share some code and wanted to check early in the code for the required toolboxes, how do you find out what your toolboxes use as the string in license()?
Sean de Wolski
Sean de Wolski 2015 年 6 月 9 日
編集済み: Sean de Wolski 2015 年 6 月 9 日
@IA, I don't reproduce this. Here's my 'inuse' for this current session:
>>license('inuse')
compiler
curve_fitting_toolbox
datafeed_toolbox
distrib_computing_toolbox
financial_toolbox
matlab
simulink
statistics_toolbox
symbolic_toolbox
Note: ver shows what you have installed which is different from what you've checked out in the current session. You need to use a command to pull the license:
Try license('inuse') before and after this in a fresh MATLAB session.
graythresh(imread('cameraman.tif'))
per isakson
per isakson 2015 年 6 月 9 日
編集済み: per isakson 2015 年 6 月 9 日
@IA, I reproduce your scenario and encounter the problem you describe.
On R2013a, ver says that I have "Statistics Toolbox" installed. How to check whether I have a license to run it?
>> license('inuse')
matlab
>> license('test','Statistics Toolbox')
ans =
0
>> license('test','statistics_toolbox')
ans =
1
Thus, were can I find the string, "statistics_toolbox"?
Chad Greene
Chad Greene 2019 年 2 月 15 日
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 2019 年 2 月 15 日
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.

サインインしてコメントする。

その他の回答 (3 件)

Christian Odenthal
Christian Odenthal 2020 年 12 月 3 日
編集済み: Christian Odenthal 2020 年 12 月 3 日

1 投票

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 2018 年 7 月 26 日

0 投票

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 件のコメント

Steven Lord
Steven Lord 2018 年 7 月 26 日
Use the ver function.
Chad Greene
Chad Greene 2019 年 2 月 15 日
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)

サインインしてコメントする。

Walter Roberson
Walter Roberson 2022 年 2 月 2 日

0 投票

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.

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by