I agree with Guillaume. Depending on what alexa means, it may not be possible. MATLAB doesn't have that capability. We're not talking about a timer or checking time in a loop. We're talking about bailing out if a function does not complete in a required time - it's a different situation. I didn't understand either until someone explained it to me, so let me try to explain it here. He uses National Instruments LabView to do high speed, but relatively simple, operations on the assembly line. He explained it like this. Let's say you're examining parts coming down the assembly line and you've got 1 millsecond to analyze this part before you need to analyze the next one. And you have to examine them all - you can't skip any . But what if one pathological part comes down and is taking too long and if you finish that part, you'll miss the next one. Let's say you're calling bwconncomp() or regionprops() or similar and it's been 5 ms - well you would have missed the next 4 parts and that is unacceptable. So they (LabView) have a way to specify how long the function should take, and if it's longer than that to just bail out regardless of how far along it is . It returns a "did not finish" flag and you can mark that part as defective an move on to the next part. It might be better to flag that part as bad rather than to miss analysis of the next dozen or hundred parts while the pathological one finishes analysis. Does that make sense? As far as I know, and this other engineer knows, there is no capability to interrupt a certain function, say bwconncomp() or regionprops() in the middle yet continue on with the rest of the script. This question has come up on this forum before. I hope this explains the situation better.
On the other hand 3600 seconds is quite a long time and I don't think there's any MATLAB function that would take that long, so perhaps alexaa has the opportunity to bail out in the middle of the code by checking the elapsed time in her code, in between calls to MATLAB functions . But once a MATLAB function has started , there is no way to stop it that I know of. Perhaps if you had a separate m-file running and then totally killed off the main script and then tried to restart it and pick up where it left off. I don't know but that would be pretty tricky to make sure you're starting again with all the right values of the variables so that you can continue on as if nothing happened.