This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Time limit for computations

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.




Pref::maxTime(seconds) with seconds greater than 0 sets a time limit for all following MuPAD® instructions. Each computation not finished within the given time raises an error.

The call Pref::maxTime() returns the current value of the time limit without changing it.

The call Pref::maxTime(NIL) switches off the timer watch dog.


Example 1

No computation should take more than 10 seconds:

Pref::maxTime(10 * unit::sec):

Note that time returns the CPU time in milliseconds. The following while loop is designed to run longer than 10 seconds:

TIME:= time(): 
while time() - TIME < 20000 do null() end_while
Error: Execution time exceeded. [watchdog-time]
Pref::maxTime(NIL): delete TIME:



The time limit in seconds: a nonnegative integer or an expression involving time units.

Return Values

Previously defined time limit: 0 or an expression involving unit::sec.

See Also

MuPAD Functions

Was this topic helpful?