I was given some matlab code. How do I figure out what toolboxes are necessary to run the code?

4 visualizaciones (últimos 30 días)
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?

Respuestas (4)

bio lim
bio lim el 15 de Jul. de 2015
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
John D'Errico el 15 de Jul. de 2015
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.

David Andres
David Andres el 15 de Jul. de 2015
Well that is one way of doing it but this means I need to purchase matlab with no toolboxes. Then try it out and see if there are errors. Then track down which toolboxes are needed for the functions that generated errors. Then place another order for the toolboxes required. This seems a little in efficient are you sure there is not a better way?
  2 comentarios
Stephen Farrington
Stephen Farrington el 27 de Feb. de 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.
Steven Lord
Steven Lord el 27 de Feb. de 2024
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))
Running fmincon requires 2 products.
fprintf("Required product: %s\n", productList.Name)
Required product: MATLAB Required product: Optimization Toolbox

Iniciar sesión para comentar.


Steven Lord
Steven Lord el 15 de Jul. de 2015
Use the tools described in the documentation.

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by