Borrar filtros
Borrar filtros

How can I show user defined classes?

3 visualizaciones (últimos 30 días)
Michael
Michael el 5 de Mayo de 2014
Comentada: Michael el 19 de Mayo de 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 comentarios
Geoff Hayes
Geoff Hayes el 5 de Mayo de 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 el 19 de Mayo de 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)

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by