Main Content

ModelAdvisor.Table

为模型顾问结果创建表

说明

ModelAdvisor.Table 对象在模型顾问结果中创建和格式化表。指定表的行数和列数,不包括表标题和表题头行。

创建对象

描述

示例

table = ModelAdvisor.Table(row,column) 创建一个包含指定行数和列数的表对象。

输入参数

全部展开

模型顾问结果表中要创建的表行数。

模型顾问结果表中要创建的表列数。

对象函数

getEntry从模型顾问分析结果的表中获取单元格内容
setColHeading为模型顾问分析结果中的表指定列标题
setColHeadingAlign指定列标题对齐方式
setColHeadingValign指定列标题垂直对齐方式
setColWidth指定列宽
setEntriesSpecify contents of table in Model Advisor analysis results
setEntrySpecify content cell in table in Model Advisor analysis results
setEntryAlign为模型顾问分析结果中的表指定单元格对齐方式
setEntryValign指定表单元格垂直对齐
setHeading为模型顾问分析结果中的表指定标题
setHeadingAlignSpecify table title alignment
setRowHeading指定表的行标题
setRowHeadingAlignSpecify table row title alignment
setRowHeadingValignSpecify table row title vertical alignment

示例

全部折叠

创建一个会出现在模型顾问结果中的表。该表有五行五列,包含随机生成的数字。

在回调函数中使用以下 MATLAB® 代码。模型顾问在结果中显示 table1

matrixData = rand(5,5) * 10^5;

% Initialize a table with 5 rows and 5 columns (heading rows not counting).
table1 = ModelAdvisor.Table(5,5);

% Set column headings
for n=1:5
    table1.setColHeading(n, ['Column ', num2str(n)]);
end

% Center the second column heading
table1.setColHeadingAlign(2, 'center');

% Set column width of the second column
table1.setColWidth(2, 3);
 
% Set the row headings
for n=1:5
    table1.setRowHeading(n, ['Row ', num2str(n)]);
end

% Enter table content
for rowIndex=1:5
    for colIndex=1:5
        table1.setEntry(rowIndex, colIndex, ...
            num2str(matrixData(rowIndex, colIndex)));
        
        % set alignment of entries in second row
        if colIndex == 2
            table1.setEntryAlign(rowIndex, colIndex, 'center');
        end
    end
end

% Overwrite the content of cell 3,3 with a ModelAdvisor.Text  object
text = ModelAdvisor.Text('Example Text'); 
table1.setEntry(3,3, text)

The table "table1" with the text 'Example Text' in Row 3 Column 3

版本历史记录

在 R2006b 中推出