Documentation

license

Get license number or perform licensing task

Syntax

  • status = license('test',feature) example
  • license('test',feature,toggle)
  • [status,errmsg] = license('checkout',feature) example

Description

license returns the license number for this MATLAB® product. The return value also can be 'demo' for a demonstration version of MATLAB, 'student', for a student version of MATLAB, or 'unknown', if the license number cannot be determined.

example

license('inuse') displays a list of licenses checked out in the current MATLAB session. The product list is alphabetical by license feature name. These names are the same as the valid values for the feature input.

example

S = license('inuse') returns an array of structures indicating checked-out licenses and the user name of each person who has a license checked out.

example

S = license('inuse',feature) checks if the product specified by feature is checked out in the current MATLAB session. If the product is checked out, then license returns the product name and the user name of the person who has it checked out. Otherwise, the fields of S are empty.

example

status = license('test',feature) tests if a license exists for the product specified by feature.

license('test',feature,toggle) enables or disables testing of the product specified by feature, depending on the value of toggle.

example

[status,errmsg] = license('checkout',feature) checks out a license for the specified product. If you specify the optional second output argument, errmsg, then license returns the text of any error message encountered if the checkout is unsuccessful.

Examples

collapse all

Display Licenses in Use

Display a list of licenses currently being used.

license('inuse')
image_toolbox
map_toolbox
matlab

license displays a list of products in alphabetical order by the license feature name.

Get Licenses in Use and User Names

Get a list of licenses in use with information about each user.

S = license('inuse');

license returns a structure array.

View the first element of S.

S(1)
ans = 

    feature: 'image_toolbox'
       user: 'juser'

Determine If License Is in Use

Determine if the license for MATLAB is in use.

S = license('inuse','MATLAB')
S = 

    feature: 'matlab'
       user: 'jsmith'

If the license is in use, then S is a structure array with nonempty fields.

Determine If License Exists

Determine if a license exists for Mapping Toolbox™.

status = license('test','map_toolbox')
status =

    1

license returns 1 if a license exists.

Check Out License

Check out a license for Control System Toolbox™.

[status,errmsg] = license('checkout','control_toolbox')
status =

     1


errmsg =

     ''

The status output is 1 and the errmsg output is empty if the checkout is successful.

Input Arguments

collapse all

feature — License feature namestring

License feature name, specified as a string. The INCREMENT lines in a license file indicate the valid strings. To locate your license file, see Where are the license files for MATLAB located?

As an example, this table lists the feature value for a few commonly used products.

feature ValueMathWorks® Product
'MATLAB'MATLAB
'SIMULINK'Simulink®
'Control_Toolbox'Control System Toolbox
'Curve_Fitting_Toolbox'Curve Fitting Toolbox™
'Signal_Blocks'DSP System Toolbox™
'Image_Toolbox'Image Processing Toolbox™
'Optimization_Toolbox'Optimization Toolbox™
'Distrib_Computing_Toolbox'Parallel Computing Toolbox™
'Signal_Toolbox'Signal Processing Toolbox™
'Stateflow'Stateflow®
'Statistics_Toolbox'Statistics and Machine Learning Toolbox™
'Symbolic_Toolbox'Symbolic Math Toolbox™

Values of feature are not case-sensitive.

toggle — Ability to test product license'enable' | 'disable'

Ability to test the existence of a product license, specified as either 'enable' or 'disable'.

  • If toggle is 'enable', then the syntax, license('test',feature) returns 1 when the product license exists and 0 when the product license does not exist.

  • If toggle is 'disable', then the syntax, license('test',feature) always returns 0 (product license does not exist) for the specified product.

    Note   Disabling a test for a particular product can affect other tests for the existence of the license, not just tests performed by the license command.

Output Arguments

collapse all

S — Checked out productsarray of structures

Checked out products, returned as an array of structures, where each structure represents a checked-out license. The structures contain two fields:

  • feature — license feature name

  • user — user name of the person who has the license checked out

If the fields are empty, then the product is not currently checked out.

status — Test or checkout status1 | 0

Test or checkout status, returned as 1 or 0.

  • When testing for the existence of a license, 1 indicates that the license exists, and 0 indicates that the license does not exist.

    The existence of a license does not necessarily mean that the license can be checked out or that the product is installed. status is 1 even if the license has expired or if a system administrator has excluded you from using the product.

  • When checking out a license, 1 indicates that the checkout is successful, and 0 indicates that the license function could not check out a license.

errmsg — Error messagestring

Error message for unsuccessful license checkout, returned as a string. If the checkout is successful, then errmsg is empty.

See Also

Introduced before R2006a

Was this topic helpful?