MATLAB: GUI push button with delay

gui push button dealy

I have two files where first button should run in first click and after delay the second file should run . Any comments or command to delay a second file to run.

Best Answer

You can create a timer object to delay the execution of a function. Here is an example:
SecondFunction = @() disp([' ... ' num2str(toc) ' seconds have elapsed ...']) ;
TimerHandle = timer('StartDelay',2,'TimerFcn','SecondFunction()') ;
tic ;
start(TimerHandle)
disp('Hello, I am going to be busy for about four seconds ...')
pause(4) % ... busy ...
disp(['Now it is ' num2str(toc) ' seconds later, so ... Goodbye!'])