首页 > 解决方案 > 如何自动更改 M 文件中已在两个 Matlab 版本之间删除/更改的函数?

问题描述

我正在寻求流程自动化方面的帮助。简而言之,我有一份在 2011a 和 2018b 中编写的 Matlab 代码/应用程序列表(总共 30 个)。这意味着超过 100 000 个具有 .m 或 .p 扩展名的文件,其中许多包含已更改/删除的功能。我想自动化迁移过程,如下所述:

1.  Make a list of all matlab functions that have changed/removed between the 2011a release and the 2018b release (Has been done already)
2.  Get all the m-files and p-files that exist in a specific directory (store them in a variable), (Has been done already)
3.  Automatically open each file (defined as above) then:
    a.  Scan each line of code and
    b.  If any of the function listed above appear in the code, then:
        I.  If it’s simply changed name (i.e same syntax and same number of arguments) then:
            •   automatically replace it everywhere in the code
            •   Save and close the file
        II. If the syntax of the function has changed for example the function takes one more or one less argument, then do the following:
            •   Show where the function appears in the code
            •   Let the user manually change it once (dialogue box)
            •   Then automatically apply the new syntax everywhere else in the code to replace the old syntax
            •   Save the file and close it 
        III.    Otherwise: save and close the file

标签: matlabautomationmigration

解决方案


推荐阅读