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

201 次查看(过去 30 天)

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2024-1-25
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by