Determining toolbox dependency of a series of scripts

4 views (last 30 days)
Hi there
I am trying to determine the toolbox dependency of a handful of scripts, all run using the "MainScript.m". I am using the two separate calls:
[fList,pList] = matlab.codetools.requiredFilesAndProducts('MainScript.m');{pList.Name}'
names = dependencies.toolboxDependencyAnalysis({'MainScript'});names'
which gives me about the same results. Both insist that the scripts require the "Statistics and Machine Learning Toolbox". However, when performing a "dependency report" on the MainScript I find no apparent reason why this Toolbox should be necessary. I.e.: my question is this: how do I figure out, specifically, why that Toolbox is required by my scripts?

Answers (1)

Johannes Korsawe
Johannes Korsawe on 20 Jan 2016
Edited: Johannes Korsawe on 20 Jan 2016
i am also struggling with that functionality.
The short answer is: There is no functional command in Matlab that will return the exact toolboxes, whose licenses you will need to run your code. The returned toolboxes' names just indicate a POSSIBLE dependency.
I have found numerous malfunctions in all dependency-analyzing tools, that Matlab provides, that you would not expect. They can be explained, but it is not the expected result. There are different results across the tools, across the releases and across the folders of the source files if you place the very same file in two different folders. Some reasons for unexpected results:
  • usage of MATLAB keywords from some toolbox as identifier for a user-variable
  • usage of MATLAB keywords from some toolbox as identifier for a user-function
  • dependent functions, that are not on the path, will not be analyzed
  • bugs in the "which" functionality, on which the dependency-checker are based
So my advice is: Make sure that you are not using any MATLAB keywords for variables and/or function-names. Check this by using the {which -all keyword} command.
Regards, Johannes

Community Treasure Hunt

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

Start Hunting!