Clear Filters
Clear Filters

How to display a table object in command window in a different color

2 views (last 30 days)
Hi
I am working with tables and I was wondering how to display the table in a different color. I know you can use the cprintf function for regular strings but it doesn't work if I try to pass an object table.
Ideally it should be something like this
MyTable = table (1, 2, 3)
disp(MyTable,'r')

Accepted Answer

Jan
Jan on 9 Aug 2017
There is no direct way. You have to create a string at first, e.g. using evalc('disp(MyTable)').
This suffers from the same problems as eval and assignin, but if you do not use this to create variables, but catch the string output only, there is a chance that it does not make your code evil.
Are you really sure that this is useful? What about the output to a specific GUI? The command window has very limited possibilities only, and squeezing them might not be useful. As soon as more sophisticated output is required, a HTML display in a GUI might be smarter at all.

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!