Problem with debugging in MATLAB

9 次查看(过去 30 天)
Hello all. My program in MATLAB opens at the beginning of the program figure in GUI, and then the program changes the positions of up to 16 images in each loop. when I try to debug my program, I get different subroutines that MATLAB opens by itself and sometimes I can't even stop the program because the program always jumps to another subroutine. matlab opens several of those subroutines, I'll show you 3 of them. I would like to ask why this is happening and if I should consider it as a error in my program. otherwise the program runs smoothly

采纳的回答

Peng Li
Peng Li 2020-3-25
If everytime you use step in during debug, MATLAB will step in each subroutine and sub-subroutines, and so on, because it's own functions may call another function, and several other functions might be called again and again.
After the program stops at where your breakpoint is, you can try to click the line where you want the program to stop, and click Run until cursor to let the program stop there.
Hopefully this is what you need.
  2 个评论
Miroslav Jiránek
Miroslav Jiránek 2020-3-25
the program runs in an endless loop. sometimes I need to stop the simulation and look at the state of the variables, but mostly when I stop the program, it's in some subroutine and the state of the variables is not visible, respectively outdated. Is it possible to make sure that the program always returns to my code after pressing "pause" button?
Peng Li
Peng Li 2020-3-25
I don't think this is possible. You have to explicitely add a breakpoint where you want the program to stop. Otherwise, after you click the pause button, it stops anywhere random. You can nevigate back to your m file and click anywhere after a somewhat transparent triangle sign in front of the line where the program stops (it's actually a subroutine used in that line), and click Run until cursor.
It's not ideal i think. It's better to add a breakpoint where you want to check the state.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by