[PTB] how to cancel running a function with a timer?
    3 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    lou
 le 26 Nov 2015
  
    
    
    
    
    Modifié(e) : Walter Roberson
      
      
 le 26 Nov 2015
            Hi,
I am trying to make a loop in MatLab Psychtoolbox that runs the GetClicks function for 2 seconds and then stops running it. But mu current function gets stuck in the GetClicks function. By getting stuck I mean that it won't leave the loop before a subject has clicked on the screen, but I would like to have the option to leave the loop also when subject has not clicked with a mouse. I also need o save the coordinates of the mouse click (these determine what answer the subject gave).
Any ideas how to solve it?
 tic;
      state=0;
      while state==0;
          time=toc;
          if time < 2 %subject should have 2seconds to reply
              [clicks,x,y] = GetClicks;
              if clicks==1
                  state=1;
              end
          elseif time> 2
              state=1;
              clicks=99;
          end
      end
0 commentaires
Réponse acceptée
  Walter Roberson
      
      
 le 26 Nov 2015
        
      Modifié(e) : Walter Roberson
      
      
 le 26 Nov 2015
  
      Since you are working with PsychToolbox routines, you should really be checking with their mailing list or online resources.
It looks to me as if the answer might be
global ptb_mouseclick_timeout;
old_timeout = ptb_mouseclick_timeout;
ptb_mouseclick_timeout = 2;
clicks = GetClicks([],0);
ptb_mouseclick_timeout = old_timeout;
state = clicks > 0;
0 commentaires
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Timing and presenting 2D and 3D stimuli dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!