ModelAdvisor.Table

Class: ModelAdvisor.Table
Package: ModelAdvisor

Create table

Syntax

  • table = ModelAdvisor.Table(row, column) example

Description

example

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.

Examples

expand all

Create two table objects

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 table with five rows and five columns

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

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

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

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

Was this topic helpful?