3

I have a package of code that's been written by someone else. I am running a script, which calls some functions, which in turn calls some more functions, etc. I would like to get the list of functions that are not MATLAB built-in functions but are a part of the package.

I tried using matlab.codetools.requiredFilesAndProducts('file.m'), which gives me a list of such functions, but not all the functions. I can see when I look at the code that there are many more functions called by a function in the script. Does this command only show 'first-level' functions? How can I get the full list?

2
  • 1
    One possibility would be to use the profiler (e.g. here. It will list all functions that the programme calls during its execution. Commented May 15, 2015 at 19:04
  • This toolbox (m2html) artefact.tk/software/matlab/m2html seems to list all functions called within a function, for example see its own documentation as in artefact.tk/software/matlab/m2html/doc Commented May 15, 2015 at 20:10

3 Answers 3

2

This function performs well, but isn't guaranteed to get all files. Works fine for me though

http://www.mathworks.com/matlabcentral/fileexchange/15484-recursively-get-file-dependencies-of-a-given-function/content/getFileDependencies.m

Sign up to request clarification or add additional context in comments.

2 Comments

Do we know why it's not guaranteed to get all files? Or in what cases it would miss some?
This gives the same output as matlab.codetools.requiredFilesAndProducts and gives the following warning: Warning: DEPFUN will be removed in a future release. Use matlab.codetools.requiredFilesAndProducts instead.
1

Check out the function inmem which may help to solve this task. It displays all matlab functions that are currently in memory. Thus it lists those functions that have been recently called, i.e. that have been called since the last clear allor clear functions statement. Thus you would start with a clean workspace, execute your program, and check with inmem which functions are loaded into the cache and are not in the matlab install directory, those are the functions you are interested in.

You may also use the command-line helper disp-inmem that was scripted to (half-)automate this task.

Comments

0

From: https://www.mathworks.com/help/matlab/matlab_prog/identify-dependencies.html

[fList,pList] = matlab.codetools.requiredFilesAndProducts('myFun.m');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.