Info

此问题已关闭。 请重新打开它进行编辑或回答。

Time managed program in MATLAB

1 次查看(过去 30 天)
Vatsal Gupta
Vatsal Gupta 2018-7-1
关闭: MATLAB Answer Bot 2021-8-20
Is there any specific function or code which enables the code to run for a specified amount of time, like say, 10 minutes. The code execution is done as normal and the running of it dies after a period of time.
  3 个评论
Vatsal Gupta
Vatsal Gupta 2018-7-1
编辑:Vatsal Gupta 2018-7-1
It should halt the program execution, then and there only. Actually I'm working on a program which works for a specified time only and the changing state of the workspace variables are monitored in that period of time.
dpb
dpb 2018-7-1
Sorry, I don't understand. Are you asking about how to stop a program after some time period, not that a program fails unexpectedly after some time?
If so, what time unit is of interest; wall clock time, CPU time (tougher all the time (so to speak :) ) any more with multi-cores, etc., etc., ), some simulation internal time, something else entirely, ...?

回答(1 个)

Walter Roberson
Walter Roberson 2018-7-1
If you use the Parallel Computing Toolbox, then you can use parfeval() to start a process running with a "future". You can wait() for the future with a timeout. If the timeout expires, then cancel() the future.

此问题已关闭。

标签

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by