evalWithTimer

版本 1.0.0.0 (5.3 KB) 作者: Anver Hisham
Execute a command within the specified time-limit, or kill the process.
339.0 次下载
更新时间 2016/9/13

查看许可证

Running complicated tasks sometimes take huge amount of execution time in matlab. Supose you want to stop running a command, if it takes too much execution time, then this is the code for you. Using function 'evalWithTimer', you can spcify the command to execute (1st input), and maximum time-limit in seconds (2nd input). If the command execution takes more time than the specified time-limit, then this program automatically kills the process and returns a non-zero status value.

-EXAMPLES

1. Compute the square root of 123 within 100 seconds, and store it in variable 'a' in the workspace
status = evalWithTimer('a=sqrt(123)',100)

2. Solve a linear program with 'n' variables in 1 hour
n=10^5; A=rand(n)-0.5; b = rand(n,1)-0.5; f = rand(n,1)-0.5;
status = evalWithTimer('x = linprog(f,A,b)',3600)

引用格式

Anver Hisham (2026). evalWithTimer (https://ww2.mathworks.cn/matlabcentral/fileexchange/59120-evalwithtimer), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2015b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Get Started with MATLAB 的更多信息
版本 已发布 发行说明
1.0.0.0