Debugger running different code than normal runner
Show older comments
Hello, I've been using app designer to try and create a UI for some analysis that we're currently doing. When I try to change the axes/plot positions, it works when I run it using debug mode, but it does not work when I run it normally.
I was able to recreate it with a simple test case.
Adding two axes in a simple grid layout (image 1) with the following code (image 2):
app.UIAxes.Position = [100 150 200 300];
app.UIAxes2.Position = [300 350 400 500];
If I were to put a breakpoint on the first line, press run and then continue, the results are what is expected with the graphs out of place (image 3). However, if I were to run it without any breakpoints, the runner treats it as if the code wasn't there (image 4). I was wondering if someone could help me get it to work normally, without having to use breakpoints to work around this bug.
Image 1

image 2

image 3

image 4

Answers (1)
Walter Roberson
on 30 Aug 2022
Moved: Steven Lord
on 31 Aug 2022
0 votes
Add a drawnow() ?
5 Comments
Steven Lord
on 31 Aug 2022
That was my first thought as well. The reason that your code running in debug mode may not need a drawnow is, I believe, related to the More About section on the documentation page for the drawnow function.
"These actions are equivalent to calling a full drawnow command:
- Returning to the MATLAB® prompt.
- Using the getframe, pause, and waitfor functions.
- Using functions that wait for user input, such as waitforbuttonpress, input, keyboard, or ginput."
I believe reaching the debug prompt K>> counts as the first bullet.
Walter Roberson
on 31 Aug 2022
Technically, debugger counts as using keyboard() , which is why the prompt is K>>
Mingda He
on 31 Aug 2022
Walter Roberson
on 31 Aug 2022
please post the code for testing... my version of MATLAB cannot execute pictures of code.
Mingda He
on 1 Sep 2022
Categories
Find more on Develop Apps Using App Designer 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!