How do I determine the required toolboxes and licenses for my MATLAB code?

374 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 12 Sep 2024
Edited: MathWorks Support Team on 14 Aug 2024
To fetch a list of toolbox dependencies for MATLAB files, consider the following methods:
 

Option 1 - Use the "matlab.codetools.requiredFilesAndProducts" function

Use the matlab.codetools.requiredfilesandproducts function to identify MathWorks products and other user-authored files a MATLAB file depends on. For example:
>> [fList,pList] = matlab.codetools.requiredFilesAndProducts('myFun1.m');
>> fList
    'C:\work\myFun1.m'    'C:\work\myFun2.m'
>> {pList.Name}'
ans =
'MATLAB'
'Image Processing Toolbox'
In this case, 'myFun1.m' requires both MATLAB and the Image Processing Toolbox, as well as the user-written file 'myFun2.m'.
To analyze multiple MATLAB files, use the following syntax:
>> filesArray = {'test1.m', 'test2.m'};
>> [fList, pList] = matlab.codetools.requiredFilesAndProducts(filesArray);
NOTE: This method performs static analysis and does not account for runtime information. It may incorrectly include dependencies for overloaded functions with the same name but different parameters.
 

Option 2 - Use the "license" function

You can check the licenses that have been checked out by using the license function.Restart MATLAB and run the MATLAB file for which you wish to determine the toolboxes used. Then, enter the following command in the MATLAB prompt:
>> license('inuse')
NOTE: This approach depends on the execution of the code. If there are parts of the code are not executed, dependencies for these parts might be missing.
 

Option 3 - Use the Dependency Analyzer app

You can use the "Dependency Analyzer" app to find the files required by a MATLAB project, a folder, or a single file. The required toolboxes will be listed on the right side of the diagram. To see the toolboxes for a specific file, click on the file in the diagram and the list on the right will only show the dependencies for that file.
NOTE: Until R2022b, the Dependency Analyzer is only available for MATLAB Projects. Starting in R2023a, you can access Dependency Analyzer from the MATLAB apps gallery to perform a dependency analysis on files and folders that do not belong to a project.
 

Option 4 - Use the "dependencies.toolboxDependencyAnalysis" function

Refer to the following link for the documentation of this function:
NOTE: This function is only available when Simulink is installed.

More Answers (0)

Categories

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

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!