Matlab: how to find functions on path that use a given function

岁酱吖の 提交于 2019-12-20 20:27:17

问题


It sometimes happens that I need to change the behavior of a function. Is there an easy way to find functions (on the matlab path) that use that function?


回答1:


The way I do this is to look for files that contain the name of the function I'm interested in. Thus, I don't only see who calls my function, but also what signature they use.

In the editor: Edit->Find Files




回答2:


Start with help deprpt.

EDIT: when I run a dependency report there are 3 checkboxes at the top of the report window. One of these, by default unchecked, is called 'Show parent functions (current folder only)'. That is probably the beginning of what you want but it only works in a single folder.

If you want more than that, I suggest that you try edit deprpt.m.




回答3:


I would use a tool like grep. I posted a tool called mgrep on the file exchange a few years ago. It can search through entire directories of m-files for any given string, and it searched recursively down into sub-directories. So to find functions in my directories that call fminsearch, I would merely execute this at the command line.

mgrep('fminsearch','.','show','off') Searching directory(ies)...

/Users/woodchips/Desktop/My_FEX/cylinderfit.m /Users/woodchips/Desktop/My_FEX/fminspleas.m /Users/woodchips/Desktop/My_FEX/fminspleas2.m /Users/woodchips/Desktop/My_FEX/fminspleas3.m /Users/woodchips/Desktop/My_FEX/fminspleasnnls.m /Users/woodchips/Desktop/My_FEX/BoundedFSOLVE/fsolvebnd.m /Users/woodchips/Desktop/My_FEX/FMINSEARCHBND/fminsearchbnd.m ...




回答4:


you mean like looking for dependencies? that would be tools -> show dependency report



来源:https://stackoverflow.com/questions/2629294/matlab-how-to-find-functions-on-path-that-use-a-given-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!