Exit while loop and close screens after 10 mouse presses

4 ビュー (過去 30 日間)
Katerina Tetzloff
Katerina Tetzloff 2015 年 10 月 23 日
コメント済み: Walter Roberson 2015 年 10 月 24 日
I am using Psychtoolbox to design a fake experiment. I have all of the code correct, but I can't get it to close after 10 mouse clicks. I tried to start the whole thing with for i=1:10, with the actual code in a while loop under this for loop, but I don't know how to relate i with number of mouse clicks.
Thank you!
  1 件のコメント
Walter Roberson
Walter Roberson 2015 年 10 月 24 日
How are you detecting mouse clicks?

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

採用された回答

Stalin Samuel
Stalin Samuel 2015 年 10 月 24 日
i = 0;
f = figure;
while i<11
w = waitforbuttonpress;
if w == 0
i =i+1;
if i ==10
close all;
break;
end
end
end
  3 件のコメント
Katerina Tetzloff
Katerina Tetzloff 2015 年 10 月 24 日
I am using the psych toolbox. My code uses [x, y, b]= GetMouse to record the (x,y) coordinates of the cursor whenever the mouse is clicked. I would like to have the window close after 10 clicks have been recorded.
Walter Roberson
Walter Roberson 2015 年 10 月 24 日
Then you can just use a for loop, since only one click will be registered for each iteration of the loop.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by