"Steven Lord" <
Steve...@mathworks.com> wrote in message <lh19fb$p8m$
1...@newscl01ah.mathworks.com>...
>
> In general? No, I don't believe there is a way to time out an arbitrary
> function call (short of killing MATLAB or _maybe_ on Linux sending SIGINT to
> the MATLAB process. I haven't tried the latter, but I have done the former.)
>
> For specific functions, you could have the TimerFcn of a timer set some
> application data (SETAPPDATA) that the function queries (with GETAPPDATA)
> periodically; if the application data says to stop, the function could then
> stop.
>
Thanks, Steve. The app data idea is good, except that I am worried about getting stuck in certain subfunctions of the main function (working with videos, so can take some time depending on video size) which I do not control and hence, would not be able to query the app data.
I spent a few hours working on this, but in the end went with a supervisor in Linux that restarts the process if it doesn't respond with the output of the function within a set amount of time. It's better than killing from within MATLAB I think, because in extreme CPU cases like a blank "while true" loop, MATLAB seems to be blocking TimerFcn from executing until the loop is somehow exited.