필터 지우기
필터 지우기

How to wait for an button event with a timeout?

조회 수: 5 (최근 30일)
Marta
Marta 2015년 11월 19일
댓글: Marta 2015년 12월 3일
Hi!
I am looping in time through a series of images and I want to give a chance for the user to interact with them between updates. However, I do not want to ask the user at every single update whether they want to interact or not. Ideally I would like to implement something like this:
figure
for t=tini:tfin
imagesc(squeeze(ima(:,:,t))
waitforbuttonpress_for_no more_than_200_ms;
if there_was_a_buttonpress
do_something_to_figure;
end
end
Can you help? Many thanks,
Marta

채택된 답변

Walter Roberson
Walter Roberson 2015년 11월 19일
  댓글 수: 1
Marta
Marta 2015년 12월 3일
This is exactly what I needed, Walter, many thanks!

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

추가 답변 (1개)

dpb
dpb 2015년 11월 19일
  댓글 수: 2
Marta
Marta 2015년 11월 19일
And how is the event tracked during the pause?
dpb
dpb 2015년 11월 19일
"I don't do windows" <:) so I'm certainly not the best to ask but don't use waitforbuttonpress, set a callback function for the figure instead.
Seems like a reasonable enhancement request to TMW to add a timeout to it, however, maybe.

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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by