Track number of times a function is referenced within a folder/file in MATLAB?

dependencies, function, matlab, refactoring

Solution

For this I typically use the find files funcionality (found in the menu on top of your screen) with the 'contains' option. Especially if your function name does not match common variable names this works very well.

Just search in the entire matlab path, or in the specific directory for something like `myFun(` and you will see all the places where it is called. In the worst case you will also find some places where it is not called.

Problem

I have a large project going with 40+ functions and it's just increasing every day. Often times I reference a function multiple times from different scripts. Every once in a while, I'll find that I need to edit a function for one script, and then I realize that it's possible that I want that function to stay the same for another script. Obviously this in itself is no problem; I can just write a new function. But sometimes I don't remember if I've referenced that function anywhere else in my larger folder containing all my scripts! Is there a way in MATLAB to somehow find a count of how many times a function is used within a folder? If so, is there a way to track where it's being referenced from? Thanks in advance =).

Original source

Related problems