How to find out all the functions/mfiles that calls a specific function/mfile?

50 views (last 30 days)
I create some functions and mfiles. And I want to change the name of a function, say 'wantchang'. However, 'wantchang' is called by some others(function or mfile). How to find all the mfile that calls 'wantchang'?
  4 Comments
Adam
Adam on 5 May 2016
Use 'Find Files' from the editor and make sure it includes everything on your path. If your search phrase is common and used in other contexts it can be a problem, but usually a mixture of matching case and whole word narrows it down.

Sign in to comment.

Answers (1)

Jan
Jan on 5 May 2016
Edited: Jan on 5 May 2016
You can use one of the dependency reporters from the file exchange:
But searching for "wantchang(" would be easier: Click on "Find Files" in the editor, "Find Files containing text", "Look in entire Matlab path" and select "Include subfolders" on demand to consider @Object and /private folders.
If you have to change less than 100 occurrences, I'd prefer to aplly the changes manually, because the automatic replacement is dangerous.
Searching for "wantchang(" fails, if you have code like:
wantchang (Args)
wantchang NonfunctionalForm
wantchang ...
(Arguments, in, the, next, line)
feval('wantchang', Args)
eval(lower('WANTCHANG(ARGS)'))
fcn = @wantchang;
fcn(Args)
Pcoded files are not considered also. In such cases the dependency reporters are smarter.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!