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!