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 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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -