Filter löschen
Filter löschen

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

234 Ansichten (letzte 30 Tage)
I would like to determine the license and toolbox dependencies for my MATLAB file.

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 21 Mai 2024 um 0:00
Bearbeitet: MathWorks Support Team am 21 Mai 2024 um 20:34
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 Note: This method does static analysis. Information only available during execution time won't be used for the analysis. For example, for functions that share the same name but have different input parameters, which function should be called can only be decided during run time. So this approach may include the wrong function in the dependency for overloaded functions. 

 

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
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.

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

Weitere Antworten (0)

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by