timeout

版本 1.0.0.0 (1.1 KB) 作者: Mikhail
Interrupt execution of script or function after specified period of time
617.0 次下载
更新时间 2017/1/24

查看许可证

Interrupt execution of script, function or MATLAB expression after specified period of time. Similar to timeout from GNU coreutils.
This function uses undocumented command window method to programatically send Ctrl+C after specified period of time.

There are other ways of sending Ctrl+C programmatically, including Java Robot or SIGINT on Linux, but they require changes to the script or function that we want to interrupt.

This submission serves as a PoC and demonstration. Adapt to your specific needs if necessary.

Usage examples

Run the 'longComputations' script for no more than 5 seconds:
>> timeout('longComputations',5)

Interrupt execution of infinite pause after 3 seconds:
>> timeout('pause(inf)',3)

引用格式

Mikhail (2024). timeout (https://www.mathworks.com/matlabcentral/fileexchange/61263-timeout), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2016b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Call Python from MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0