Is there any way to set time limit on a function?
55 views (last 30 days)
Sean de Wolski on 15 Apr 2015
Pass tic into the function and have it check toc periodically. If it exceeds, return or error.
Adam on 15 Apr 2015
You can use tic toc.
Just run with a while loop, extracting the toc value into a variable and testing that it is less than your chosen time in the while loop.
You could also use a timer object, but tic toc is simpler in this case I would think.
Jan on 16 Apr 2015
How do you want to stop the external function? Is it possible to stop it in a regular way or do you have to kill the process in the hard way? The second method might leave some partially written output files and other junk on your computer.
You can start the external function using system('Program.exe &') and wait the wanted time. The exact procedure depends on how the external function can show, that it has finished and on your operating system. So please add more details in the body of your question - posting this as a comment is not optimal for the readers.