waitforbuttonpress not working after print call

6 ビュー (過去 30 日間)
Haebom
Haebom 2018 年 1 月 5 日
コメント済み: Haebom 2018 年 1 月 9 日
Hi, weird thing is happening in my code.
for i=1:5
% Some prior codes
print(sprintf('%s/%s', outputdir, filename), '-dpng');
key = waitforbuttonpress;
value = double(get(gcf,'CurrentCharacter'));
end
After drawing some plots on a figure, I save it using print and then confirm the result via wiatforbuttonpress and then move to the next figure. It works as intended only if I remove the print line. Otherwise, it doesn't continue to the next loop. More interesting thing is, if I run the code step by step, there is no problem. It saves the figure and waits for a button press and then continues to the next loop. Did I do something wrong?

採用された回答

Chris Perkins
Chris Perkins 2018 年 1 月 8 日
Hi Haebom,
I have replicated this on my end, and observed similar behavior. From what I saw, it appears that mouse clicks are still picked up by "waitforbuttonpress", but key clicks are not when the "print" line is included. It's possible there is an issue with "waitforbuttonpress".
I work at MathWorks, and have forwarded this information to the respective team, so they can look into the issue.
In the meantime, you should be able to use a mouse click instead of a key click as a workaround.
  1 件のコメント
Haebom
Haebom 2018 年 1 月 9 日
Hi Chris, thank you so much for your quick feedback. The problem is, I want to get a key input and record it for each figure in the loop. I solved this problem by separating it into two phases, one for recording key inputs without 'print', and the other one for only 'print' figures into files. I hope it is fixed in the next version.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!