Get license status, test existence of license, or check out feature license
Use the license function to return the license number in use, list the licenses checked out in the current session, determine if a particular feature on the license is checked out, and check out a specific feature on the license. To perform license management tasks, including how to renew or deactivate a license, see Manage Your Licenses.
license returns the license number for this MATLAB®. The return value may also be a non-number, for example,
'demo' for a demonstration version of MATLAB, or
'student', for a student version of
array of structures listing the features checked out in the current
S = license('inuse')
Display Licenses in Use
Display a list of licenses currently being used.
license displays a list of features in alphabetical
order by the license feature name for your configuration.
image_toolbox map_toolbox matlab
Get Licenses in Use
Get a list of licenses in use.
returns a structure array.
S = license('inuse');
View the first element of
ans = feature: 'image_toolbox' user: ''
Although the structure contains a user field, that field is always empty.
Determine If License Is in Use
Determine if the license for MATLAB is in use. If the license is in use, then
a structure array with the name of the feature that is checked out.
S = license('inuse','MATLAB')
S = feature: 'matlab' user: ''
Determine If License Exists
Determine if a license exists for Mapping Toolbox™. If a license exists, then
status = license('test','MAP_Toolbox')
status = 1
Check Out License
Check out a license for Control System Toolbox™. The
status output is
errmsg output is empty if the checkout is
[status,errmsg] = license('checkout','Control_Toolbox')
status = 1 errmsg = ''
feature — License feature name
License feature name, specified as a character vector. Values of
feature are not case-sensitive. The
INCREMENT lines in a license file indicate the valid
features. To locate your license file, see Where can I find MATLAB license files?
toggle — Ability to test license
Ability to test the existence of a license, specified as either
'enable', then the syntax,
1when the license exists and
0when the license does not exist.
'disable', then the syntax,
0(license does not exist) for the specified feature.
Disabling a test for a particular license can affect other tests for
the existence of the license, not just tests performed by the
S — Checked out licenses
array of structures
Checked out licenses, returned as an array of structures, where each structure represents a checked-out license. The structures contain two fields:
feature— License feature name
user— A field that is always empty
If both fields are empty, then the license is not currently checked out.
status — Test or checkout status
Test or checkout status, returned as
When testing for the existence of a license,
1indicates that the license exists, and
0indicates that the license does not exist.
The existence of a license does not necessarily mean that the license can be checked out or that a feature on the license is installed. If all the keys of a license are in use, then the test will still return 1, but a real checkout will fail.
When checking out a license,
1indicates that the checkout is successful, and
0indicates that the
licensefunction could not check out a license.
errmsg — Error message
Error message for unsuccessful license checkout, returned as a character
vector. If the checkout is successful, then
Error messages usually indicate how you can resolve the issue. For example:
License checkout failed. License Manager Error -5 Cannot find a license for FEATURENAME. Troubleshoot this issue by visiting: https://www.mathworks.com/support/lme/R2021b/5
The license checkout error you get can depend on what type of license you have.
Sign in to your MathWorks® Account for details about all licenses linked to your account, such as license type, feature use, and expiration information.
To perform license management tasks, including how to renew or deactivate a license, see Manage Your Licenses.
Run code in the background using MATLAB®
backgroundPool or accelerate code with Parallel Computing Toolbox™
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version HistoryIntroduced before R2006a
R2023a: license('inuse') returns empty character vector in user field
In previous releases, the username returned was incorrect under certain circumstances. The returned structure user field is now always returned empty.
If you need to make changes to your code, the command
getenv('USERNAME') is recommended instead.
getenv('USERNAME') works in all releases.
|Before R2023a||R2023a and later|
X = license('inuse'); Y = X.user;
X = license('inuse'); Y = getenv('USERNAME');