This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Class: ModelAdvisor.Table
Package: ModelAdvisor

Create table


table = ModelAdvisor.Table(row, column)



table = ModelAdvisor.Table(row, column) creates a table object (table). The Model Advisor displays the table object containing the number of rows (row) and columns (column) that you specify.


expand all

Create two table objects, table1 and table2. The Model Advisor displays table1 in the results as a table with one row and one column. The Model Advisor display table2 in the results as a table with two rows and three columns.

table1 = ModelAdvisor.Table(1,1);
table2 = ModelAdvisor.Table(2,3);

Create a table with five rows and five columns containing randomly generated numbers.

Use the following MATLAB® code in a callback function. The Model Advisor displays table1 in the results.

% ModelAdvisor.Table example

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)]);

% set alignment of second column heading
table1.setColHeadingAlign(2, 'center');

% set column width of second column
table1.setColWidth(2, 3);

% set row headings
for n=1:5
    table1.setRowHeading(n, ['Row ', num2str(n)]);

% set 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');

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