Add a title to a table built with syntax - AUCtable = table(x, y, z)
6 次查看(过去 30 天)
显示 更早的评论
I have built a table
AUCtable = table(x, y, z)
how do I print it out 'nicely' -- without getting ans = lots of information type of syntax??
display(AUCtable) and AUCtable prints out
AUCtable
2 new lines
numRows x numCols table
2 new lines
then the table
I could probably live with that -- if I could add a title -- and AUCtable.Properties.Description ='My title' does not work
Thanks
0 个评论
采纳的回答
Star Strider
2021-3-9
I am not exactly certain what you want as the end result.
Try this:
x = rand(5,1); % Create Vector
y = rand(5,1); % Create Vector
z = rand(5,1); % Create Vector
T1 = table(x,y,z); % Create Original Table
T2 = table(T1, 'VariableNames',{'My Title'}); % Create ‘Super Table’
get_x = T2.('My Title').x; % Retrieve Sample Data
producing:
T2 =
5×1 table
My Title
x y z
______________________________
0.25515 0.9368 0.00665
0.16694 0.77852 0.8626
0.19633 0.59893 0.011251
0.60822 0.5609 0.95496
0.59116 0.83691 0.97722
And of course:
disp(T2)
also works, producing simply:
My Title
x y z
_______________________________
0.053157 0.68624 0.20949
0.66566 0.39679 0.37425
0.5316 0.019607 0.31304
0.44307 0.53647 0.84004
0.28418 0.883 0.24669
.
7 个评论
Star Strider
2021-3-9
I am not certain what the problem is (or was). I submitted an enhancement request asking that (1) the six-column table displays as it should, with the title displayed above the variable names as it does with the three-column table, and (2) that adding the option of a table title would be an interesting addition.
So while ‘T2’ does not display as you (or I) would like it to (all six columns with their variable names),
get_x = T2.('My Title').x; % Retrieve Sample Data
continues to work correctly, so all is not lost.
This was an interesting problem!
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!