1

我有几张表格,在命令窗口中生成之后,我需要将屏幕打印到 Word 文档中。是否可以给表格一个标题,这样它就不需要在报告中进一步标记。

或者有没有办法删除它说桌子的大小。下面是我生成表格的代码。首先有没有更好的方法来创建表。大多数搜索只返回有关链列和/或行标题的详细信息。

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

谢谢!

4

1 回答 1

3

table没有标题。一种解决方法是先打印文本,然后打印表格。从MATLAB中获取示例表:

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 。

于 2019-04-25T16:52:23.930 回答