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

2 次查看(过去 30 天)

采纳的回答

MathWorks Support Team

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by