How can I show user defined classes?
4 次查看(过去 30 天)
显示 更早的评论
So in Matlab clear classes is a pretty important command. But how can I show classes that I have defined, i.e. those that would be cleared by clear classes?
2 个评论
Geoff Hayes
2014-5-5
Michael - I don't think that there is a way to list all user-defined classes. You can type whos from the Command Window to get a list of all currently instantiated variables and see their class names from that.
Is your concern that clear classes will cause you to lose class information? Because all it does is clear the currently loaded definitions for all classes (or those that you specify) which means that the next time you create an instance of a user-defined class, then the latest definition of that class will be used.
For example, suppose I have a 128-bit unsigned integer class called uint128. I create several instances of the class:
x = uint128(1233);
y = unit128(3455);
z = x+y;
I observe that the addition did not work as expected (the wrong result was returned). So I make some changes to the class definition uint128.m file. But those changes don't come into affect until I do a clear all or clear classes because it the old class definition is still being used. So I just type clear classes and then repeat the above example to see if the addition finally worked.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!