You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
Imagine you have a long-running function:
[out1,out2,out3,...] = longRunning(arg1,arg2,arg3,...)
and this function is being run many times with the same inputs. If you change this to:
[out1,out2,out3,...] = cacheFunction(@longRunning,arg1,arg2,arg3,...)
then only the first instance will run long, further calls will be grabbed from a global variable 'functionCache'. This only recaculates results when the inputs change.
Thanks to Christopher Wipf for most of the code.
Cite As
Nicolas Smith (2026). cacheFucntion.m (https://www.mathworks.com/matlabcentral/fileexchange/44650-cachefucntion-m), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.1.0.0 (1.52 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
