如何附加到正在运行的Matlab脚本 [英] How to attach to a running Matlab script

查看:138
本文介绍了如何附加到正在运行的Matlab脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何附加到正在运行的Matlab脚本(即我用F5执行的m文件)?它运行了好几天(我有一个无限的while循环),我想了解出什么问题了(应该在某个时候退出它).我知道我可以重新运行它并设置一个断点,但这不是我要的.我现在想在循环内设置一个断点,然后停止该进程并对其进行调试. Matlab不允许我设置断点.

How can I attach to a running Matlab script (i.e. a m-file which I have executed with F5 ) ? It runs since days (I have an infinite while loop) and I want to understand what is wrong (it should exit it at some point). I know I can rerun it and set a breakpoint but that is not what I am asking. I wanna set a breakpoint NOW inside the loop and stop the process and debug it. Matlab does not allow me to set a breakpoint.

推荐答案

不幸的是,Matlab不允许这样做.要变通解决此问题,我在项目的关键点调用此函数:

Unfortunately Matlab does not allow this. To work around this problem I call this function at critical points in a project:

function cxdebug()
    f='c:\cxdebug';
    if exist(f,'file')
        try, delete(f);end
        keyboard;
    end
end

创建文件后,下次调用该函数时,matlab将进入调试器.

Once you created the file, matlab will enter the debugger when the function is called next time.

这篇关于如何附加到正在运行的Matlab脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆