Figure freezes during input() command on Windows

조회 수: 3(최근 30일)
Matt J Dunn
Matt J Dunn 2017년 2월 9일
댓글: Matt J Dunn 2017년 2월 15일
I am writing a program that allows the user to select a data point on a figure using datacursormode() and simultaneously awaits input from an input() command. On MATLAB 2016b (Mac), this works fine; I can select a point without any problems. On Windows, the figure window freezes and only updates when the program advances beyond the input() line. Consequently, I can't see my data cursor (it only appears when the program moves on).
I understand about the command drawnow(), but I need to be able to wait for the user to select a data point in the figure and then press a key to indicate that they are happy with their selection.
The code works as follows:
<2D data drawn to figure window>
dataCursor = datacursormode(gcf);
set(dataCursor,'DisplayStyle','datatip','SnapToDataVertex','off','Enable','on'); % change to 'data cursor mode'
userType = input('Select data point, then press enter. Type ''end'' to end >','s'); % FIGURE WINDOW FREEZES HERE

답변(1개)

Harsh
Harsh 2017년 2월 15일
Hello,
Are you using MATLAB R2016a? There was a bug with that version that was fixed in R2016b. The bug report and more details can be seen here:
One possible workaround worth trying is to use 'pause(0.5)' statement before the call to the input function.
  댓글 수: 1
Matt J Dunn
Matt J Dunn 2017년 2월 15일
No; I am using MATLAB R2016b.

댓글을 달려면 로그인하십시오.

범주

Find more on Graphics Performance 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!

Translated by