matlab - How to overload clear -
overloading clear()
function easy. how access workspace of upstream function (from clear
called) clear workspace? builtin('clear')
clear workspace of overloaded function.
function ret = somefun(a,b) ret = + b; clear ret = 1; end function clear() persistent boring if isempty(boring), boring = 0; end boring = boring + 1; builtin('clear') end
screenshot: workspace of upstream function after calling overloaded clear
function
use evalin
'caller'
option. is, replace line
builtin('clear')
by
evalin('caller', 'builtin(''clear'')')
this clear variables workspace of caller function.
should want want clear variables matlab base workspace, use 'base'
option:
evalin('base', 'builtin(''clear'')')
Comments
Post a Comment