필터 지우기
필터 지우기

Add a title to a table built with syntax - AUCtable = table(x, y, z)

조회 수: 1 (최근 30일)
Michael
Michael 2021년 3월 9일
댓글: Michael 2021년 3월 9일
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

채택된 답변

Star Strider
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
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!
Michael
Michael 2021년 3월 9일
Thanks Walter -- I meant fail to display as I want -- rather than fail /crash

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Michael
Michael 2021년 3월 9일
disp(AUTtable) -- and answered my own first question by mistake <GROAN>
Adding a title still defeats me

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by