【问题标题】:Shifting control between compiled matlab code在编译的 matlab 代码之间切换控制
【发布时间】:2012-10-09 22:19:08
【问题描述】:

所以我有两段已编译的 matlab 代码(在 exe 中)。我想要以下行为:

一个exe文件(exefile1)调用另一个,使用'system('exefile2')'。另一个文件(exefile2)运行并在完成其功能后,将控制权返回给调用文件(exefile1)。但由于某种原因,exefile2 并没有返回控制,而只是完成并返回到命令提示符。他们是实现我想要的方式吗?

【问题讨论】:

    标签: matlab matlab-compiler


    【解决方案1】:

    您的描述中没有详细说明,但我尝试了以下方法,效果很好。

    第一个脚本(hello.m):

    try
        disp('hello');
        system('hi.exe');
        disp('hello');
    catch
        fprintf('%s', exc.getReport('extended'))
    end
    

    第二个脚本(hi.m):

    try
        disp('hi')
    catch
        fprintf('%s', exc.getReport('extended'))
    end
    

    try-catch 在这里有点不必要,但在编译时它总是有帮助的。总之,基本思路是:

    hello starts
    hello prints hello
    hello starts hi
    hi prints hi and returns
    hello prints hello again
    end
    

    我将这两个脚本编译为 Console Application 并在命令提示符下运行它,它工作正常:

    hello
    hi
    hello
    

    所以我不确定你的具体问题是什么,但基本想法很好......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 2012-05-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多