Is there a way to search for function calls recursively without running the program?

3 vues (au cours des 30 derniers jours)
In Visual Studio, the "View Call Hierarchy" option allows you to see everywhere a function is called, where the caller is called, etc., all the way up the hierarchy. This can be done without running the program. Is there a way to do something like this in MATLAB? It seems like you either need to use the "Find Files" feature and manually follow the hierarchy or look at the call stack at run-time.
  2 commentaires
Rik
Rik le 24 Fév 2022
Matlab is very dynamic when it comes to functions vs variables. You might be able to borrow code from my minify function to automatically extract the names from every function that is called. With some calls to which you should be able to find the file locations of those functions.
The performance will probably be terrible, but it should (mostly) work. The tools linked on the page that Matt suggested might also help you create something.
Kyle Padilla
Kyle Padilla le 28 Fév 2022
Okay thanks for the advice. I'll see if I can create anything using the references you and Matt provided.

Connectez-vous pour commenter.

Réponses (2)

Steven Lord
Steven Lord le 28 Fév 2022
Static analysis can only get you so far. What function gets called by these two lines of code (omitting the block comment lines) assuming userSpecifiedMatfile contains a MAT-file name?
%{
data = load(userSpecifiedMatfile);
plot(data.x)
%}
Which of the N functions named plot does that second line call?
which -all plot
built-in (/MATLAB/toolbox/matlab/graph2d/plot) /MATLAB/toolbox/matlab/graphfun/@digraph/plot.m % Shadowed digraph method /MATLAB/toolbox/matlab/datatypes/tabular/@tabular/tabular.m % Shadowed tabular method /MATLAB/toolbox/matlab/timeseries/@timeseries/plot.m % Shadowed timeseries method /MATLAB/toolbox/matlab/polyfun/@polyshape/plot.m % Shadowed polyshape method /MATLAB/toolbox/matlab/polyfun/@alphaShape/plot.m % Shadowed alphaShape method /MATLAB/toolbox/matlab/bigdata/@tall/plot.m % Shadowed tall method /MATLAB/toolbox/matlab/graphfun/@graph/plot.m % Shadowed graph method /MATLAB/examples/wavelet/data/@wvtree/plot.m % Shadowed wvtree method /MATLAB/examples/wavelet/data/@edwttree/plot.m % Shadowed edwttree method /MATLAB/examples/wavelet/data/@rwvtree/plot.m % Shadowed rwvtree method /MATLAB/toolbox/bioinfo/bioinfo/@phytree/plot.m % Shadowed phytree method /MATLAB/toolbox/bioinfo/microarray/@HeatMap/plot.m % Shadowed HeatMap method /MATLAB/toolbox/bioinfo/microarray/@clustergram/plot.m % Shadowed clustergram method /MATLAB/toolbox/coder/half/@half/plot.p % Shadowed half method /MATLAB/toolbox/curvefit/curvefit/@cfit/plot.m % Shadowed cfit method /MATLAB/toolbox/curvefit/curvefit/@sfit/plot.m % Shadowed sfit method /MATLAB/toolbox/econ/econ/@conjugateblm/plot.m % Shadowed conjugateblm method /MATLAB/toolbox/econ/econ/@diffuseblm/plot.m % Shadowed diffuseblm method /MATLAB/toolbox/econ/econ/@mixconjugateblm/plot.m % Shadowed mixconjugateblm method /MATLAB/toolbox/econ/econ/@lassoblm/plot.m % Shadowed lassoblm method /MATLAB/toolbox/econ/econ/@mixsemiconjugateblm/plot.m % Shadowed mixsemiconjugateblm method /MATLAB/toolbox/econ/econ/@empiricalblm/plot.m % Shadowed empiricalblm method /MATLAB/toolbox/econ/econ/@blm/plot.m % Shadowed blm method /MATLAB/toolbox/econ/econ/@customblm/plot.m % Shadowed customblm method /MATLAB/toolbox/econ/econ/@semiconjugateblm/plot.m % Shadowed semiconjugateblm method /MATLAB/toolbox/finance/ftseries/@fints/plot.m % Shadowed fints method /MATLAB/toolbox/ident/ident/@iddata/plot.m % Shadowed iddata method /MATLAB/toolbox/ident/nlident/@idnlarx/plot.m % Shadowed idnlarx method /MATLAB/toolbox/ident/nlident/@idnlhw/plot.m % Shadowed idnlhw method /MATLAB/toolbox/mpc/mpc/@mpc/plot.m % Shadowed mpc method /MATLAB/toolbox/robust/rctobsolete/robust/@frd/plot.m % Shadowed frd method /MATLAB/toolbox/robust/robust/@umargin/plot.m % Shadowed umargin method /MATLAB/toolbox/shared/channel/rfprop/@propagationData/plot.m % Shadowed propagationData method /MATLAB/toolbox/shared/drivingscenario/@drivingScenario/plot.m % Shadowed drivingScenario method /MATLAB/toolbox/signal/signal/@dspdata/plot.m % Shadowed dspdata method /MATLAB/toolbox/stats/classreg/@LinearModel/plot.m % Shadowed LinearModel method /MATLAB/toolbox/wavelet/wavelet/@dtree/plot.m % Shadowed dtree method /MATLAB/toolbox/wavelet/wavelet/@wdectree/plot.m % Shadowed wdectree method /MATLAB/toolbox/wavelet/wavelet/@ntree/plot.m % Shadowed ntree method

Matt J
Matt J le 18 Fév 2022
  3 commentaires
Matt J
Matt J le 25 Fév 2022
I was hoping for something more focused on functions specifically,
Isn't that the case with the tools I mentioned?
Kyle Padilla
Kyle Padilla le 28 Fév 2022
It looked to me like the dependecy report focuses more on the files themselves rather than functions within them. Maybe I just don't fully understand the tools.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by