Last active
January 20, 2017 15:46
-
-
Save mpizenberg/bb5eacc211847409cbd9ef38c10256bc to your computer and use it in GitHub Desktop.
Transform a matlab function into a cached function (result stored in a file).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function varargout = cached(cache_filepath, f, varargin ) | |
if exist(cache_filepath, 'file') == 2 | |
load(cache_filepath, 'varargout'); | |
else | |
[varargout{1:nargout}] = f( varargin{:} ); | |
save(cache_filepath, 'varargout'); | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment