Main Content

rehash

Refresh function and file system path caches

Description

example

rehash updates the MATLAB® list of known files and classes for folders on the search path that are not in matlabroot. It compares the timestamps for loaded functions against their timestamps on disk, and it It clears loaded functions if the files on disk are newer. These actions automatically occur each time MATLAB displays the Command Window prompt. Run rehash with no arguments only when you run a program file that updates another program file, and the calling file needs to use the updated version of the second file before the calling file has finished running.

Note

Changes to class files cannot be applied while objects based on the old class files still exist in the workspace. Use clear to remove objects from the workspace.

rehash path performs the same updates as rehash, except that it unconditionally updates the list of known files and classes for all folders on the search path that are not in matlabroot. Run rehash path if you receive a warning during MATLAB startup that MATLAB could not tell if a folder has changed, and you encounter problems with MATLAB not using the most current versions of your program files.

rehash toolbox performs the same updates as rehash path, except that it updates the list of known files and classes for all folders on the search path, including those in matlabroot. Run rehash toolbox if you change, add, or remove files in matlabroot during a session. Typically, you should not make changes to files and folders in matlabroot.

rehash toolboxcache performs the same updates as rehash toolbox, and also updates the cache file. This syntax is equivalent to clicking the Update Toolbox Path Cache button, located in the General Preferences page of the Preferences window.

Examples

collapse all

Within a program file, programmatically edit the file myFunction.m and use rehash to refresh the cached list of known files and functions so that the program file can access the updates to myFunction.

fopen("myFunction.m")

% Make changes to myFunction

fclose("myFunction.m")
rehash

x = myFunction()

Version History

Introduced before R2006a