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

194 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 19 Jan 2024
Edited: MathWorks Support Team on 25 Jan 2024
Given some existing MATLAB files, there are several methods of fetching a list of toolboxes that the project is dependent on. These are listed below:

1. Using the "matlab.codetools.requiredFilesAndProducts" function:

You can use the "matlab.codetools.requiredFilesAndProducts" function to show which MathWorks products a particular MATLAB file or function depends on. Additionally, the function returns a list of other user-authored MATLAB files required by the file.
Here is an example to determine the toolbox dependencies of the user-written MATLAB file 'myFun1.m':
>> [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);
Refer to the following link for the documentation of this function:https://www.mathworks.com/help/matlab/ref/matlab.codetools.requiredfilesandproducts.html 

 

2. Using the "license" function

You can check the licenses that have been checked out by using the "license" function. You can do so by following these steps:
1. Start MATLAB.2. Run the MATLAB file in which you wish to determine the toolboxes used.3. Enter the following command in the MATLAB prompt:
>> license('inuse')
Refer to the following MathWorks documentation link for more details:
https://www.mathworks.com/help/matlab/ref/license.html

3. Create a MATLAB Project to use Dependency Analyzer

NOTE: MATLAB Projects are only available in MATLAB R2019a and later releases.
When working with a large number of MATLAB files, it might be more convenient to (temporarily) add the files to a MATLAB project and use the project "Dependency Analyzer" (formerly "Dependency Analysis") feature to find the required files. The required toolboxes will be listed on the right side of the diagram. In order 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.
Refer to the following link for the documentation of this feature:https://www.mathworks.com/help/releases/R2023a/matlab/matlab_prog/analyze-project-dependencies.html (adjust the URL to match your MATLAB release)
Information regarding the creation of MATLAB Projects can be found here:https://www.mathworks.com/help/matlab/matlab_prog/create-projects.html

4. Using the "dependencies.toolboxDependencyAnalysis" function:

NOTE: This function is only available when Simulink is installed.
Refer to the following link for the documentation of this function:http://www.mathworks.com/help/simulink/slref/dependencies.toolboxdependencyanalysis.html

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!