How do I determine the required toolboxes and licenses for my MATLAB code?
    231 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    MathWorks Support Team
    
 il 5 Giu 2023
  
    
    
    
    
    Risposto: Image Analyst
      
      
 il 10 Ott 2025 alle 19:08
            I would like to determine the license and toolbox dependencies for my MATLAB file.
Risposta accettata
  MathWorks Support Team
    
 il 18 Set 2025
        
      Modificato: MathWorks Support Team
    
 il 10 Ott 2025 alle 18:38
  
      To fetch a list of toolbox dependencies for MATLAB files, consider the following methods:
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'
>> {pList.Certain}
ans =
 1x2 cell array
    {[1]} {[1]}
The Certain field has a value of 1 if matlab.codetools.requiredFilesAndProducts determines the product is required by the specified program files, files, or a value of 0 if the product is possibly required. 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.
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.
NOTE: A toolbox "A" may contain functions that call functions belonging to another toolbox "B" but users do not need a license to toolbox "B". In that case, "matlab.codetools.requiredFilesAndProducts" will not list toolbox "B", but "license('inuse')" will.
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.
Refer to the dependencies.toolboxDependencyAnalysis documentation.
NOTE: This function is only available when Simulink is installed.
0 Commenti
Più risposte (1)
  Image Analyst
      
      
 il 10 Ott 2025 alle 19:08
        Attached is a utility function I wrote.
This is what's in it:
% List required files and toolboxes.  Displays them in the command window or console window (if deployed).
% Sample call
% 		fullFileName = [mfilename('fullpath'), '.m'];
%       DisplayRequiredFunctions(fullFileName)
% It takes a long time to run so that's why I only do it in the development environment.
function DisplayRequiredFunctions(fullFileName)
try
    if ~isdeployed
        [~, baseFileNameNoExt, ext] = fileparts(fullFileName);
        baseFileName = [baseFileNameNoExt, '.m'];
        [requiredFileList, toolboxList] = matlab.codetools.requiredFilesAndProducts(fullFileName);
        fprintf('Required m-files for %s:\n', baseFileName);
        for k = 1 : length(requiredFileList)
            fprintf('    %s\n', requiredFileList{k});
        end
        fprintf('Required MATLAB Toolboxes for %s:\n', baseFileName);
        for k = 1 : length(toolboxList)
            fprintf('    %s\n', toolboxList(k).Name);
        end
    end
catch ME
end
0 Commenti
Vedere anche
Categorie
				Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

