How do I list all my dependent m-Files?
26 ビュー (過去 30 日間)
古いコメントを表示
I want to generate a list of all the dependent m-files for a particular MATLAB script file that I wrote (just my own functions, not built-in functions). I used to know how to do this, but it has been a few years.
0 件のコメント
回答 (5 件)
Image Analyst
2019 年 6 月 4 日
Try this:
% List required files and toolboxes. Displays them in the command window or console window (if deployed).
% Sample call
% fullFileName = [mfilename('fullpath'), '.m'];
% DisplayRequiredFunctions(fullFileName)
% It takes a long time to run so that's why I only do it in the development environment.
function DisplayRequiredFunctions(fullFileName)
try
if ~isdeployed
[~, baseFileNameNoExt, ext] = fileparts(fullFileName);
baseFileName = [baseFileNameNoExt, '.m'];
[requiredFileList, toolboxList] = matlab.codetools.requiredFilesAndProducts(fullFileName);
fprintf('Required m-files for %s:\n', baseFileName);
for k = 1 : length(requiredFileList)
fprintf(' %s\n', requiredFileList{k});
end
fprintf('Required MATLAB Toolboxes for %s:\n', baseFileName);
for k = 1 : length(toolboxList)
fprintf(' %s\n', toolboxList(k).Name);
end
end
catch ME
end
3 件のコメント
Mabee
2019 年 8 月 7 日
Dear Image Analyst,
I used matlab.codetools.requiredFilesAndProducts for a similar problem. But I found that it only lists the dependencies that I actually have. It does not seem to list the dependencies that are missing.
I inherited a very complex script that calls long chains of functions and I am trying to figure out which ones are missing.
Thanks for any more advice
Image Analyst
2012 年 2 月 7 日
Try the "Tools->Save and Show Dependency Report" from the MATLAB pulldown menus, or else try these File Exchange submissions:
To me, fdep looks like the most comprehensive.
3 件のコメント
Image Analyst
2012 年 2 月 7 日
編集済み: per isakson
2019 年 8 月 7 日
That's true. That's when I discovered fdep. It finds EVERYTHING, including stuff Dependency Report might miss. Make a shortcut on your toolbar and paste this code, then be sure to change the folder in my code from "C:\Program Files\MATLAB\work\UserExamples\fdep" to where YOU have fdep saved.
% Examine an m-file for what toolboxes or other m-files it calls.
addpath(genpath('C:\Program Files\MATLAB\work\UserExamples\fdep'));
% Let the user browse for the m-file.
[baseFileName, folder] = uigetfile('*.*', 'Specify an m-file');
% fprintf(1, 'baseFileName = %s\n', baseFileName);
% Create the full filename.
fullFileName = fullfile(folder, baseFileName);
if exist(fullFileName, 'file')
fprintf(1, 'Running fdep on %s\n', fullFileName);
%cd('C:\Program Files\MATLAB\work\UserExamples\fdep');
% Get its dependencies by passing it to the fdep function.
p=fdep(fullFileName);
p.list();
else
fprintf(1, 'User clicked Cancel. fdep() was not run.\n');
return;
end
Sean Lynch
2015 年 11 月 5 日
depfun has been replaced with matlab.codetools.requiredFilesAndProducts
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!