Skip to Main Content Skip to Search
Product Documentation

mlock - Prevent clearing function from memory

Syntax

mlock

Description

mlock locks the currently running function in memory so that subsequent clear functions do not remove it. Locking a function in memory also prevents any persistent variables defined in the file from getting reinitialized.

Use the munlock function to return the file to its normal, clearable state.

Examples

The function testfun begins with an mlock statement.

function testfun
mlock
  .
  .

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

testfun

mislocked('testfun')
ans =
     1

Using munlock, you unlock the testfun function in memory. Checking its status with mislocked shows that it is indeed unlocked at this point.

munlock('testfun')

mislocked('testfun')
ans =
     0

See Also

inmem | mislocked | munlock | persistent

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS