命令clear classes
清除当时加载到内存中的所有类定义。
是否可以仅清除特定的类定义?
编辑:我有兴趣删除特定的课程定义来自内存,而不是类实例。
当我编写新的 HPF 类时,我自己也遇到了这个问题。所以我尝试了一些事情,因为当我调试新类时,我需要进行许多更改,然后进行测试。
“清除功能”没有帮助。我什至尝试过“clear hpf”。但清除所有实例似乎确实可以做到这一点。例如:
>> x = hpf(3);
>> x+2
ans =
5
>> whos
Name Size Bytes Class Attributes
ans 1x1 248 hpf
x 1x1 248 hpf
y 1x1 8 double
所以现在我对类做了一个小小的更改并保存了它。
>> z = hpf(17);
Warning: The class file for 'hpf' has been changed; but the change cannot be applied because objects based on the old class file still exist. If you use
those objects, you might get unexpected results. You can use the 'clear' command to remove those objects. See 'help clear' for information on how to remove
those objects.
>> clear functions
>> clear hpf
>> clear x
>> clear z
>> x = hpf(3);
Warning: The class file for 'hpf' has been changed; but the change cannot be applied because objects based on the old class file still exist. If you use
those objects, you might get unexpected results. You can use the 'clear' command to remove those objects. See 'help clear' for information on how to remove
those objects.
所以我仍然收到警告,告诉我 MATLAB 仍然有问题。然而,我的内存中仍然有一个很容易忘记的 HPF 实例,ans。
>> clear ans
>> clear x
>> whos
Name Size Bytes Class Attributes
y 1x1 8 double
>> x = hpf(3);
>> x+23
ans =
26
只要我也删除了该实例,MATLAB 就不再向我发出警告。请注意,我从来不需要发出“清除类”命令。变量 y(双精度型)仍然存在来证明这一事实。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)