如何删除变量"clear".在MATLAB中 [英] How to remove the variable "clear" in MATLAB

查看:522
本文介绍了如何删除变量"clear".在MATLAB中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您是一些新程序员,并且您做了类似的事情...

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 = 0;
end 

或通过其他方式分配变量 clear 值.

or in some other way, you assign the variable clear a value.

是否可以通过某种方式清除" clear?

Is there some way to "clear" clear?

clearvars 不起作用.单击工作区变量并手动单击删除确实可以,但是我认为这是作弊.

clearvars doesn't work. Clicking the workspace variable and manually clicking delete does work, but I think it's cheating.

推荐答案

这可以做到:

builtin('clear','clear')

注意:请记住避免此类操作,以保持代码清晰.仅在您要执行的确切操作时才进行覆盖.否则,如果您忘记了(或其他人使用您的代码并且没有意识到)您清除了(或其他任何)函数,则可能会导致将来的错误.例如,您可以轻松地将该变量命名为doClear.

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.

这篇关于如何删除变量"clear".在MATLAB中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆