Is it possible to reflect changes in a file saved to a folder on the MATLAB path under $MATLABROOT$\toolbox?

2 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 28 Dec 2009

MATLAB has toolbox cache which contains a list of all of the files located in the toolbox directories ($MATLABROOT$\toolbox) and all of their subdirectories. If a function is already in memory, MATLAB uses the cache on subsequent calls to the function. It is faster for MATLAB to run the files from the cache than it is to reload the files. The cache is used for toolbox directories because they should not be changing very often (if at all).

After MATLAB 6.0 (R12), when a file is saved and if that file is located in $MATLABROOT$\toolbox, toolbox cache is updated to reflect the latest version of the file. So when you run the file next time, it should reflect the changes.

If for some reason the changes are not reflected, you can force MATLAB to reload the function into cache. In order to force MATLAB to reload the function, use the CLEAR command to clear the function from memory. For example, the following code will clear 'myfcn' from memory:

clear myfcn

After 'myfcn' has been cleared from memory, the next use of 'myfcn' will force MATLAB to reload the file.

If you have changed the contents of the toolbox directories (adding/removing directories or files), then you can use the REHASH command to force MATLAB to update the toolbox cache file. For example:

rehash toolboxcache

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!