我如何找到在仿真过程中执行了哪些所有 MATLAB 文件?

How can i find which all MATLAB files have been executed during a simulation?

我是运行一个MATLAB仿真。它从一个文件 top_file.m 开始,然后调用其他一些 .m 文件,这可能确实会像那样调用其他 .m 文件。

有没有一种方法可以让我知道在模拟过程中执行了哪些文件,如果可能的话,还可以知道它们的执行顺序?

正如 Matlab's profiler 所指出的那样,工具完全可以满足您的需求,更多

您可以从命令行运行它:

>> profile clear; profile on; %// clear history and start the tool
>> top_file; %// run your code
>> profile off; %// switch off the tool
>> profile viewer; %// launch GUI to view results

在探查器的 GUI 中,您将看到调用的函数及其 运行 时间。

试试吧!这是一个非常有用的工具。

自 R2014a 以来有一个内置函数 matlab.codetools.requiredFilesAndProducts,它将 return 任何文件的依赖项列表,而无需执行它。

>> files = matlab.codetools.requiredFilesAndProducts('test.m')
files = 
    '/path/to/test.m'
    '/path/to/test.m/dependencies'