How to remove the variable “clear” in MATLAB

后端 未结 4 1198
余生分开走
余生分开走 2020-12-18 19:51

Let\'s say you are some new programmer and you do something like...

%...la da da
%...programming away
if such && such
    clear = 1;
else 
    clear          


        
4条回答
  •  无人及你
    2020-12-18 20:02

    This will do it:

    builtin('clear','clear')
    

    Note: Keep in mind to avoid such operations to keep code clarity. Only do overwrite when it is the exact action you want to take place. Otherwise it may cause future bugs if you forgot (or if another person uses your code and didn't realize it) that you have the clear (or any other) function overwritten. You could easily name this variable as doClear for example.

提交回复
热议问题