如何在MATLAB中可视化项目结构

如何在MATLAB中可视化项目结构

本文介绍了如何在MATLAB中可视化项目结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经拥有数千行Matlab代码,其中一些具有> 900行功能,还有一些目录中充满了function_name.m文件.很难弄清一切在做什么(或与之相关)或弄清依赖项.您建议如何可视化函数结构,例如从哪个函数调用哪个函数,按什么顺序调用?

I've come into ownership of several thousand lines of Matlab code, some as >900 line functions and a few directories full of function_name.m files. It's hard to figure out what everything is doing (or relating to) or figure out the dependencies. What would you suggest to visualize the functions structure, such as what functions are called from which, and in what sequence?

推荐答案

NumPy的端口.

(笑话)

通常在Matlab中,有些文件是作为函数编写的,而另一些是作为脚本编写的.脚本可以执行诸如加载要处理的数据,将其提供给函数并对其进行图形化等操作.

Usually in Matlab you have some files written as functions, and some as scripts. Scripts do things like load the data you want to process, and feed it to the functions, and graph it.

要组织事情,我将从顶层脚本开始,然后找出哪些函数进行加载,图形化,处理等工作.将脚本保存在顶层目录中,然后尝试将这些函数分成子目录.功能的目的.将函数的依赖项放入相同的子目录中.尽量使其不致目录中的任何代码依赖于父目录(或表兄弟目录)中的任何内容.

To organize things I would start at the top level script and find out which functions do the loading, graphing, processing, etc. Keep the scripts in a top level directory and try to separate the functions out into subdirectories, according to the purpose of the function. Put dependencies of a function into the same subdirectory. Try to make it so that no code in a directory depends on anything in a parent directory (or cousin directory).

每当您弄清一个函数的功能及其参数是什么时,就写一个文档注释.

Whenever you figure out what a function does and what its arguments are, write a doc comment.

这假设编写代码的人是合理的.如果不是这样,Matlab可以很容易地将所有内容都放入一个目录中,并使所有内容都依赖于摇摇欲坠的代码塔中的所有其他内容,因此您可能最终需要进行大量的重构.

This assumes the person who wrote the code was reasonable. If not, Matlab makes it easy to plunk everything down into one directory and have everything depend on everything else in a rickety tower of code, so you may end up doing a lot of refactoring.

这篇关于如何在MATLAB中可视化项目结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 17:28