MATLAB: Execute a command after a delay


Based on this thread I'm not optimistic, but thought I'd give it a try. I'd really like to be able to execute a command after a delay, e.g., run a script that says
pause(10); disp('Hullo')
but have the program continue during the pause time, so that code lines can be executed before the disp command. In linux, one could do this by "backgrounding" the command string. Maybe there's some fancy undocumented way of doing this in matlab? If not it would be a great addition.

Best Answer

Use a timer with a start delay.
T = timer('StartDelay',10,'TimerFcn',@(src,evt)disp('Hello World'));
surf(peaks) % something running while timer waiting
And for more info:
doc timer