Using a timer to execute a function
    5 ビュー (過去 30 日間)
  
       古いコメントを表示
    
    Jeff VanKerkhove
 2015 年 2 月 19 日
  
    
    
    
    
    編集済み: Giorgos Papakonstantinou
      
 2015 年 2 月 19 日
            So, I have a timer and I want to use the time to trigger an event. That is, at a certain time, I want a function (called OnFunc) to be executed.
    when time_value == 10
        OnFunc();
    end
Is there a function analogous to a 'when' statement that can execute a command when the time reaches a certain point?
0 件のコメント
採用された回答
  Giorgos Papakonstantinou
      
 2015 年 2 月 19 日
        
      編集済み: Giorgos Papakonstantinou
      
 2015 年 2 月 19 日
  
      A simple timer:
   t = timer('BusyMode', 'Drop', ...
            'ExecutionMode', 'fixedDelay', ...
            'StartFcn', [], ...
            'TimerFcn', @(obj, evd) disp('hallo'), ...
            'StopFcn', [], ...
            'Period', 2);
Issue start(t) to start the timer and stop(t) to stop it.
This timer executes the timer function @(obj, evd) disp('hallo') every 2 seconds. If the execution of the TimerFcn has not completed before the next execution, then the timer will Drop the next execution.
You can create your own callback for your TimerFcn.
At the end issue
delete(t)
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Clocks and Timers についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

