How to generate a diagram illustrating the relationship between several nested functions?
4 次查看(过去 30 天)
显示 更早的评论
I have been working with someone else's code that is quite long and full of nested functions and if conditions. I am interested in outputting some variables that are created within a nested function, that is within another nested function, that is within an if condition, etc... It is looking a little like a maze.
I was wondering if there are any ways or tools to automatically generate a diagram that illustrates how nested functions are used within a code. Something sort of like the class diagram viewer tool. Or if you have another suggestion on how to map this, I'd highly appreciate it too.
Thanks in advance!
0 个评论
回答(1 个)
John D'Errico
2023-3-1
You are asking for what is essentially a high level flow chart, produced automatically from existing MATLAB code, that shows how functions are called, the interactions of if statements, etc.
Unfortunately, there is no such automatic tool, and writing one would be a bit of a headache, certainly so for some codes if the author was determined to write bad code. For example, suppose I wrote code that used eval to create the name of a function and then call it on the fly? UGH. Yes, that would be an obscenity, but I probably know someone who would write that way.
Perhaps you might be able to use the profiler tool as something in the right direction. It would require you to run the code, fully exercising the various pathways that could be taken in the code. But if you could do that, then you would probably already know enough about the code that you would not need the required flow chart.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!