I have a MATLAB code which for some of the input cases takes an infinite time to execute. I would like to exluce from the execution of my code those input values which make my MATLAB function to take more than X minutes to execute, as MATLAB realises the execution is taking too long. Do you know any way of doing this? I could do this by concurrecy if it was written in C but I know nothing obut concurrency in MATLAB.
In fact, when I do Control-C (I am in windows) to interrupt such an infinite execution, the code actually appears to finish correctly.
Thank you very much.
If you’re running in a loop that you have some control over, you can use tic and toc to find out how long you’ve been going for, and stop if that was too long: