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)