How can I show user defined classes?

4 views (last 30 days)
Michael
Michael on 5 May 2014
Commented: Michael on 19 May 2014
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 Comments
Geoff Hayes
Geoff Hayes on 5 May 2014
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 on 19 May 2014
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)

Sign in to comment.

Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!