Debugger running different code than normal runner
显示 更早的评论
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

回答(1 个)
Walter Roberson
2022-8-30
移动:Steven Lord
2022-8-31
0 个投票
Add a drawnow() ?
5 个评论
Steven Lord
2022-8-31
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
2022-8-31
Technically, debugger counts as using keyboard() , which is why the prompt is K>>
Mingda He
2022-8-31
Walter Roberson
2022-8-31
please post the code for testing... my version of MATLAB cannot execute pictures of code.
Mingda He
2022-9-1
类别
在 帮助中心 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!