1

私の GUI の目的は、画像を表示し、ユーザーからの応答を取得することです。キーを押す (E または I) か応答なしのいずれかです。画像自体の間には、テキストを表示する 3 秒間の一時停止が必要です (a7 UIcontrolコード内)。問題は、これを 30 回行う必要があることです。そのため、タイマーを内部に持つループを使用します。しかし、GUIはうまく機能しません..

次のことを行う必要があります。

for 30 times do
    2 sec showing text (a7)
    then showing an image for 3 sec or until I\E are pressed
end

これは私のコードです。TIMER 関数とプロパティが大きく異なるため、2 つのバージョンを追加しています。

https://docs.google.com/document/d/1N6LSDAYo_DVrBCUbuPth4JPCvkI3pBNcnAZcV6Kl9wM/
より読みやすいバージョンを編集: http://pastebin.com/vd3HNGv1

写真はこちらにあります (ただし、2 枚の写真を使用できます): https://picasaweb.google.com/alex.goltser/ScrapbookPhotos

最初は、問題は常にエラーでした:

動作中にタイマーを開始しようとする

しかし、今は別のものです..

4

1 に答える 1

0

なぜタイマー関数を実行するのですか?

ループを実行する別の方法を次に示します。

for repeat = 1:30

    *show text*
    drawnow %# to make sure the graphics are updated
    pause(2) %# wait two seconds

    *show image*
    drawnow
    t = tic;
    done = false;
    while ~done && toc(t)<3 %# checks for keypress or until 3 secs
       *check for keypress*
       if E/I key has been pressed
          done = true;
       end
    end
end %# repeat 30x
于 2012-10-15T03:48:29.417 に答える