Home > OS >  How to make MATLAB identify dependency when packaging toolbox
How to make MATLAB identify dependency when packaging toolbox

Time:11-24

I have a folder where I have defined some custom scripts. Those scripts make use of functions and classes defined in toolboxes such as the Communications Toolbox and the DSP System Toolbox.

When I try to package the folder into a toolbox, the Dependency Analyzer doesn't identify any of the toolboxes that the scripts rely on. How do I rectify this?

For instance, if I have just the following lines inside a matlab script and in a matlab function file as well, both inside the folder, should MATLAB not identify the Parallel Computing Toolbox as a required add-on when packaging the folder?

gcp('nocreate')
delete(gcp('nocreate'));
parpool("local", 1);

I tried to see if MATLAB is able to tell the dependencies using the RequiredFilesAndProducts on my scripts, but even that failed to list the required toolboxes.

I have also gone through the following MATLAB pages -

  1. https://www.mathworks.com/help/matlab/matlab_prog/identify-dependencies.html : The dependency report for the code I included, correctly identifies that the Parallel Computing toolbox is being used.
  2. https://www.mathworks.com/help/matlab/ref/matlab.codetools.requiredfilesandproducts.html This doesn't list any toolboxes as dependencies for the code.

CodePudding user response:

I think this can happen if the code being analysed isn't on MATLAB's path. I put the lines you specified in a script, and when not on the path, requiredFilesAndProducts lists only MATLAB; when the script is on the path, I see this:

[a,b] = matlab.codetools.requiredFilesAndProducts('pkg/usesPctScript.m');
disp(struct2table(b))
                 Name                 Version     ProductNumber    Certain
    ______________________________    ________    _____________    _______

    {'MATLAB'                    }    {'9.12'}           1          true  
    {'Parallel Computing Toolbox'}    {'7.6' }          80          false 
    {'MATLAB Parallel Server'    }    {'7.6' }          94          false 
    {'Polyspace Bug Finder'      }    {'3.6' }         164          false 

According to the documentation, in the "Toolbox Portability" section of the "Package Toolbox" app, it states:

Products—List of MathWorks® products required by your toolbox. Create this list manually.

  • Related