How to attach to a running Matlab script

本小妞迷上赌 提交于 2020-01-24 09:24:10

问题


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.


回答1:


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

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



来源:https://stackoverflow.com/questions/35183020/how-to-attach-to-a-running-matlab-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!