如何给 matlab table 起标题?

How to give a title to a matlab table?

我有一些tables,在命令window中生成后,我需要print-screen到一个word文档中。是否可以给 table 一个标题,这样它就不需要在报告中进一步标记。

或者有没有办法删除 table 的大小。下面是我生成 table 的代码。首先有没有更好的方法来创建 table 。大多数搜索仅 return 链接列 and/or 行标题的详细信息。

T = table(Ureal(:,j), Umeth(:,j), Udiff(:,j), 'VariableNames',{'Exact', ... 'Numerical ','Difference'})

谢谢!

table 没有标题。一种解决方法是先打印文本,然后打印 table。以 MATLAB 中的 table 为例:

LastName = {'Sanchez';'Johnson';'Li';'Diaz';'Brown'};
Age = [38;43;38;40;49];
Smoker = logical([1;0;1;0;1]);
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];
T = table(LastName,Age,Smoker,Height,Weight,BloodPressure);

title = 'Table 1. My patients';

disp(sprintf('%40s',title)) % allocate 40 character spaces for the title.
disp(T)

输出:

                Table 1. My patients
LastName     Age    Smoker    Height    Weight    BloodPressure
_________    ___    ______    ______    ______    _____________

'Sanchez'    38     true        71       176       124     93  
'Johnson'    43     false       69       163       109     77  
'Li'         38     true        64       131       125     83  
'Diaz'       40     false       67       133       117     75  
'Brown'      49     true        64       119       122     80  

如果您不熟悉,也请检查 sprintf