Main Content

munlock

Allow clearing function or script from memory

Description

example

munlock(fun) unlocks the MATLAB® code file named fun. A function that is locked using mlock cannot be removed from memory with the clear command unless you first unlock it using munlock.

munlock unlocks the currently running file. Use this syntax only within a MATLAB code file.

Examples

collapse all

Create the function lockFun in your current working folder.

function lockFun()
    mlock
end

At the command prompt, call the lockFun function. Check that the function is locked.

lockFun
tf = mislocked('lockFun')
tf =

  logical

   1

Unlock the function so it can be cleared from memory. Check that the function is not locked.

munlock('lockFun')
tf = mislocked('lockFun')
tf =

  logical

   0

Input Arguments

collapse all

Name of function or script, specified as a character vector or a string scalar.

Tips

  • To determine if a file is locked, use the mislocked function.

  • To unlock a MEX file, use the mexUnlock function.

Version History

Introduced before R2006a