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

조회 수: 4 (최근 30일)
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?

답변 (4개)

bio lim
bio lim 2015년 7월 15일
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 2015년 7월 15일
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 2015년 7월 15일
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
Stephen Farrington
Stephen Farrington 2024년 2월 27일
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 2024년 2월 27일
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

댓글을 달려면 로그인하십시오.


Steven Lord
Steven Lord 2015년 7월 15일
Use the tools described in the documentation.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by