Main Content

ModelAdvisor.Table

Create table to display Model Advisor results

    Description

    Use the ModelAdvisor.Table class to create and format tables to display Model Advisor results. You can define the number of rows and columns in the table, and customize headings, alignment, and cell content.

    Creation

    Description

    table = ModelAdvisor.Table(row,column) creates a ModelAdvisor.Table object with the specified number of rows and columns to display Model Advisor results.

    Input Arguments

    expand all

    Number of rows to create in the Model Advisor results table, specified as an integer.

    Example: 5

    Data Types: int

    Number of columns to create in the Model Advisor results table, specified as an integer.

    Example: 5

    Data Types: int

    Object Functions

    getEntryGet cell contents from table
    setColHeadingSpecify column heading for table
    setColHeadingAlignSpecify horizontal alignment for column heading
    setColHeadingValignSpecify vertical alignment for column heading
    setColWidthSpecify column widths for table
    setEntriesSpecify content for all table cells
    setEntrySpecify content cell in table
    setEntryAlignSpecify horizontal alignment for cell content
    setEntryValignSpecify vertical alignment for cell content
    setHeadingSpecify title for table
    setHeadingAlignSpecify horizontal alignment for table heading
    setRowHeadingSpecify row heading for table
    setRowHeadingAlignSpecify horizontal alignment for row heading
    setRowHeadingValignSpecify vertical alignment for row heading

    Examples

    collapse all

    This example shows how to create a table with five rows and five columns in Model Advisor results, populate it with randomly generated numbers, and customize its appearance. The steps include setting column and row headings, adjusting column alignment and width, and inserting a text object into a specific cell.

    matrixData = rand(5,5) * 10^5;
    
    % Create the table
    table1 = ModelAdvisor.Table(5,5);
    
    % Set column headings
    for n=1:5
        table1.setColHeading(n, ['Column ', num2str(n)]);
    end
    
    % Align and set width for column 2
    table1.setColHeadingAlign(2, 'center');
    table1.setColWidth(2, 3);
     
    % Set row headings
    for n=1:5
        table1.setRowHeading(n, ['Row ', num2str(n)]);
    end
    
    % Enter table content
    for rowIndex=1:5
        for colIndex=1:5
            value = num2str(matrixData(rowIndex, colIndex));
            table1.setEntry(rowIndex, colIndex, value);
    
            if colIndex == 2
                table1.setEntryAlign(rowIndex, colIndex, 'center');
            end
        end
    end
    
    % Overwrite one entry with a 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

    Version History

    Introduced in R2006b