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?
댓글 수: 0
답변 (4개)
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.
댓글 수: 0
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
2015년 7월 15일
댓글 수: 2
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
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))
fprintf("Required product: %s\n", productList.Name)
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!