How to display the value of an enumeration in a table, as opposed to a 1x1 array of the enumeration class?

12 visualizaciones (últimos 30 días)
See the attached image. In my table, I have a series of asset types. Ideally, my table would display 'cash' or 'bond' instead of 1x1 Asset Type...
Is this possible?
  4 comentarios
Walter Roberson
Walter Roberson el 7 de Feb. de 2018
Hmmmm... I am finding information on customizing display of objects to the screen, but not on how to customize display within a composite structure. And for enumerations, my tests with the WeekDays demonstration enumeration seem to be ignoring the customization I am adding.
But my tests do not show the same behaviour you are describing:
>> t = table([WeekDays.Monday;WeekDays.Wednesday])
t =
2×1 table
Var1
_________
Monday
Wednesday
Is it possible that your AssetType is more than just an enumeration, or possible that you are storing a cell of enumeration values instead of individual enumeration values?
Simon Parten
Simon Parten el 8 de Feb. de 2018
See the attached screenshot. I've also tried the custom display route for the customistation of the display inside a composite structure...
without getting anywhere!

Iniciar sesión para comentar.

Respuestas (2)

Peter Perkins
Peter Perkins el 7 de Feb. de 2018
Simon, I forget exactly what release (I'm guessing R2016a or b), but sometime after tables were originally released in R2014b, the display was updated to do what I think you are asking:
>> t = table(rand(3,1),[WeekDays.Monday; WeekDays.Monday;WeekDays.Tuesday])
t =
3×2 table
Var1 Var2
_______ _______
0.48976 Monday
0.44559 Monday
0.64631 Tuesday
  3 comentarios
Simon Parten
Simon Parten el 8 de Feb. de 2018
Apologies, I think I expressed the question poorly... I don't work so much with the console so didn't think to test it :-/

Iniciar sesión para comentar.


Marco Norambuena
Marco Norambuena el 15 de Feb. de 2019
Any update on this?
  3 comentarios
Marco Norambuena
Marco Norambuena el 18 de Feb. de 2019
I don't know if this helps anybody, but at least is a quick workaround.
You can just re-cast the enumeration element by a string.
Just do
table(string([AssetType.Bond; AssetType.Flex]))
enum in table.png
Simon Parten
Simon Parten el 18 de Feb. de 2019
Yes... altough the use case is to preserve some functionality implicit in the enumeration... methods etc.
It means we need a 'view' column and an 'entitiy' column... then when you get to reporting time things get a bit weird. It's a workaorund... but for me not an attractive one :-).
But thanks for posting.

Iniciar sesión para comentar.

Categorías

Más información sobre Scripts en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by