I run a matlab script multiple times per day and a lot of times it takes too long to execute. What I want to do is set off a timer that keeps track of how long the script has been running for and stops the script when it takes longer than a specified number of seconds
I have tested this principle on a simple script:
waittime = 5;
t = timer('TimerFcn','error(''Process ended because it took too long'')',waittime);
start(t)
pause(10);
What I would expect to happen is that this function waits for 5 seconds and afterwards it will execute the stop function which is the error('Process ended because it took too long')
command.
When running this, the stop command will execute, however it does not stop the main script from running.
In my command window I see
Error while evaluating TimerFcn for timer 'timer-20'
Process ended because it took too long
Afterwards the script is not stopped, and keeps running for the full 10 seconds
I don't want this error to be cast over the TimerFcn
function, I want this error to be cast over the running script such that it stops running.
Is there any way I can control the script/function over which the error is cast?