Documentation

mlock

Prevent clearing function from memory

Syntax

mlock

Description

mlocklocks the currently running function in memory so that subsequentclearfunctions do not remove it. Locking a function in memory also prevents anypersistentvariables defined in the file from getting reinitialized.

Use themunlockfunction to return the file to its normal, clearable state.

Examples

The functiontestfunbegins with anmlockstatement.

函数testfun mlock。。

When you execute this function, it becomes locked in memory. You can check this using themislockedfunction.

testfun mislocked('testfun') ans = 1

Usingmunlock, you unlock thetestfunfunction in memory. Checking its status withmislockedshows that it is indeed unlocked at this point.

munlock('testfun') mislocked('testfun') ans = 0

Introduced before R2006a

Was this topic helpful?