Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to attach to a running Matlab script

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.

like image 486
Millemila Avatar asked Nov 27 '25 04:11

Millemila


1 Answers

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.

like image 128
Daniel Avatar answered Nov 28 '25 22:11

Daniel