0

I'm processing a data set and running into a problem - although I xlswrite all the relevant output variables to a big Excel file that is timestamped, I don't save the code that actually generated that result. So if I try to recreate a certain set of results, I can't do it without relying on memory (which is obviously not a good plan). I'd like to know if there's a command(s) that will help me save the m-files used to generate the output Excel file, as well as the Excel file itself, in a folder I can name and timestamp so I don't have to do this manually.

In my perfect world I would run the master code file that calls 4 or 5 other function m-files, then all those m-files would be saved along with the Excel output to a folder names results_YYYYMMDDTIME. Does this functionality exist? I can't seem to find it.

4

1 回答 1

1

没有内置这样的功能。

您可以使用depfunwith构建主函数的依赖关系树mfilenamedepfun(mfilename())将返回当前执行的 m 文件调用的所有函数/m 文件的列表。这将包括所有作为 MATLAB 内置文件提供的文件,您可能希望删除这些文件(并且只在您的 Excel 工作表中记录 MATLAB 版本)。

作为伪代码:

% get all files:
dependencies = depfun(mfilename());
for all dependencies:
    if not a matlab-builtin:
        copyfile(dependency, your_folder)

作为“长期”解决方案,您可能需要检查是否使用 subversion、mercurial (或许多其他系统之一)等版本控制系统适用于您的情况。在较大的项目中,这是记录用于产生特定结果的源代码版本的首选方式。

于 2013-09-23T20:39:52.757 回答