How can I show user defined classes?

1 次查看(过去 30 天)
Michael
Michael 2014-5-5
评论: Michael 2014-5-19
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
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.
Michael
Michael 2014-5-19
No, I was just trying to understand the structure of Matlab better and how I can access information that seems non-transparent (IE current user defined classes in the environment)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by