How to display the value of an enumeration in a table, as opposed to a 1x1 array of the enumeration class?
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2018-2-7
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?
回答(2 个)
Peter Perkins
2018-2-7
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 个评论
Marco Norambuena
2019-2-15
Any update on this?
3 个评论
Marco Norambuena
2019-2-18
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]))
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!