Give title for Table
이전 댓글 표시
Is it possible to give title for a table i have displayed as below
If i wanted to give a title 'My Table', how to give it?
Details = [38,71,176,124,93;...
43,69,163,109,77;...
38,64,131,125,83;...
40,67,133,117,75;...
49,64,119,122,80];
T = array2table(Details,...
'VariableNames',{'Age' 'Height' 'Weight' 'BP_High' 'BP_Low'},...
'RowNames',{'Smith';'Johnson';'Williams';'Jones';'Brown'});
disp(T)
채택된 답변
추가 답변 (2개)
Walter Roberson
2021년 5월 3일
1 개 추천
No, table() is designed for programming, not for display purposes.
댓글 수: 3
Elysi Cochin
2021년 5월 3일
Walter Roberson
2021년 5월 3일
Yes, it is possible to give a title to a table.
filename = fullfile(matlabroot, 'toolbox', 'matlab', 'datatypes', 'tabular', '@tabular', 'disp.m');
edit(filename)
Look close to the end of the first function, somewhere near line 265. You will see code that looks like
[varChars,nestedVarChars,underlines] = getVarNamesDispLines();
disp(char(varChars));
That is the line of code that displays the variable names, and the next few lines of code display headers and then the content. By this point in the code, everything has been computed and put into arrays for later display.
So just before that getVarNamesDispLines(), insert your code that figures out the title to use for the table, and then display it.
Last I recall you were using R2017a. If you were using R2018b or later you could use addprop() https://www.mathworks.com/help/matlab/ref/addprop.html to create a custom table property. Custom table properties are not displayed, but they are stored with the table, so you could addprop() a title, and then in the code for tabular disp, check to see if the property exists and if so then display it.
This is all to answer the question of whether it is possible to give a title to a table: the answer is Yes, you can modify the Mathworks-supplied code to allow for a title. If the question where whether there is any supported method, the answer would be what I originally posted: NO.
Elysi Cochin
2021년 5월 3일
Abdul Kalam.A
2022년 6월 18일
0 개 추천
if you want to display in command widow
fprintf(' your title')
tabulations = table(your parameters)
댓글 수: 1
- Don't forget to add a newline (\n) after the fprintf string,
fprintf('your title\n')
2. The table that is printed by the table() command may be truncated if it is too wide or too tall. This is why it's better to use disp
Compare the following outputs:
T = table(rand(500,1), char(randi(26,500,3)+64))
disp(T)
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!