MATLAB provides support for dependency tracking using the depfun function. depfun indicates what other functions are needed to run this function.
What you are setting is the opposite task: what functions require a given function?
Using depfun , you can do a reverse lookup. Here is a quick example:
function result = invdepfun(allFunctions, lookFor) % Return all functions that depend on a given function % % Example: invdepfun({'myfun1', 'myfun2', 'myfun3'}, 'myfun4') returns all of % 'myfun1', 'myfun2', 'myfun3' that use 'myfun4'. filename = which(lookFor); result = {}; for i = 1 : numel(allFunctions) deps = depfun(allFunctions{i}, '-quiet'); if any(strcmpi(deps, filename)) result{end + 1} = allFunctions{i}; end end end
You can use various other MATLAB functions ( which , dir , etc.) to automatically compile a list of all your functions in order to go to invdepfun as the first argument.
See also this post in File hosting .
source share