I was given some matlab code. How do I figure out what toolboxes are necessary to run the code?
Afficher commentaires plus anciens
When a user is provided matlab code how does the user figure out what toolboxes are necessary to run the code? Does matlab have a online code analyser inwhich a user can have the code analyzed to see which toolboxes are necessary?
Réponses (4)
bio lim
le 15 Juil 2015
0 votes
There might be better and easier ways, but I usually run the code first. If there are some undefined functions, or errors regarding functions etc, I usually check online and figure out which Toolboxes are necessary.
John D'Errico
le 15 Juil 2015
0 votes
Checking your code for dependencies on functions that you don't have is a terribly difficult thing to do well, since someone else might have written a code that uses their own version of something they may have named lsqlin, or fmincon. If two functions have the same name, any dependency analyzer will be unable to know the difference.
So the very best way to know is to ask the source person!
You could ask them to run the code, and check the results from depfun.
1 commentaire
David Andres
le 15 Juil 2015
David Andres
le 15 Juil 2015
0 votes
2 commentaires
Stephen Farrington
le 27 Fév 2024
It's even worse than that, since execution will halt at the first dependency on an unlicensed Toolbox. You can't know which other Toolboxes you may require until you license each one in succession. Laughably, Matlab's suggestion for solving this is to run the code "on a system that has all Toolboxes licensed" to determine which ones the code uses.
That is one possibility for small, simple code.
The documentation page to which I linked back in July 2015 offers two additional suggestions regarding dependencies, one of which is for dependencies inside a folder and one of which is the matlab.codetools.requiredFilesAndProducts function for doing exactly what the original poster asked.
As an example, what products are required to run fmincon from Optimization Toolbox?
[fileList, productList] = matlab.codetools.requiredFilesAndProducts('fmincon');
fprintf("Running fmincon requires %d products.\n", numel(productList))
fprintf("Required product: %s\n", productList.Name)
Steven Lord
le 15 Juil 2015
0 votes
Catégories
En savoir plus sur File Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!