|On this page…|
For performance reasons, MATLAB® caches toolbox folder information across sessions. The caching features are mostly transparent to you. However, if MATLAB does not see the latest versions of your MATLAB code files or if you receive warnings about the toolbox path cache, you might need to update the cache.
Upon startup, MATLAB gets information from a cache file to build the toolbox folder cache. Because of the cache file, startup is faster, especially if you run MATLAB from a network server or if you have many toolbox folders. When you end a session, MATLAB updates the cache file.
MATLAB does not use the cache file at startup if you clear the Enable toolbox path cache check box in General Preferences. Instead, it creates the cache by reading from the operating system folders, which is slower than using the cache file.
MATLAB caches (essentially, stores in a known files list) the names and locations of files in matlabroot/toolbox folders. These folders are for files provided with MathWorks® products that should not change except for product installations and updates. Caching those folders provides better performance during a session because MATLAB does not actively monitor those folders.
We strongly recommend that you save any MATLAB code files you create and any files provided by MathWorks that you edit in a folder that is not in the matlabroot/toolbox folder tree. If you keep your files in matlabroot/toolbox folders, they may be overwritten when you install a new version of MATLAB.
When you add files to matlabroot/toolbox folders, the cache and the cache file need to be updated. MATLAB updates the cache and cache file automatically when you install toolboxes or toolbox updates using the installer for MATLAB. MATLAB also updates the cache and cache file automatically when you use MATLAB tools, such as when you save files from the MATLAB Editor to matlabroot/toolbox folders.
When you add or remove files in matlabroot/toolbox folders by some other means, MATLAB might not recognize those changes. For example, when you
Save new files in matlabroot/toolbox folders using an external editor
Use operating system features and commands to add or remove files in matlabroot/toolbox folders
MATLAB displays this message:
Undefined function or variable
You need to update the cache so MATLAB will recognize the changes you made in matlabroot/toolbox folders.
To update the cache and the cache file,
The General Preferences pane is displayed.
To update the cache, use rehash toolbox. To also update the cache file, use rehash toolboxcache. For more information, see rehash.