Problem with debugging in MATLAB

9 views (last 30 days)
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

Accepted Answer

Peng Li
Peng Li on 25 Mar 2020
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 Comments
Miroslav Jiránek
Miroslav Jiránek on 25 Mar 2020
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 on 25 Mar 2020
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!