Main Content

addRow

Add row to table in Model Advisor analysis results

    Description

    example

    addRow(ftObj,rowEntries) adds a row which contains the contents of rowEntries to the end of the table specified by the formatting template object ftObj. If you do not add data to a table, Model Advisor does not display the table in the results.

    Note

    Before adding rows to a table, you must specify column titles using the setColTitles method.

    The function addRow is for formatting tables in Model Advisor analysis results with Simulink® Check™. For more information, see Simulink Check.

    For information on how to use tables in MATLAB®, see Create Tables and Assign Data to Them.

    Examples

    collapse all

    Create a Model Advisor formatting template object, ft, of type 'TableTemplate', and add a row to the table.

    Use ModelAdvisor.FormatTemplate to create a Model Advisor formatting template ft of type 'TableTemplate'.

    ft = ModelAdvisor.FormatTemplate('TableTemplate');

    Specify the table title.

    setTableTitle(ft,{'Blocks in Model'});

    Before adding rows to a table, you must specify column titles.

    setColTitles(ft,{'Index','Block Name'});

    Open the model vdp.

    vdp

    Find the blocks in the current system, vdp, and add them to the table.

    allBlocks = find_system('vdp');
    for inx = 2:length(allBlocks)
        addRow(ft,{inx-1,allBlocks(inx)});
    end

    Use addRow in a check callback function in your sl_customization file to format your Model Advisor analysis results.

    function result = SampleStyleOneCallback(system)
    ft = ModelAdvisor.FormatTemplate('TableTemplate');
    setTableTitle(ft,{'Blocks in Model'});
    setColTitles(ft,{'Index','Block Name'});
    allBlocks = find_system('vdp');
    for inx = 2:length(allBlocks)
        addRow(ft,{inx-1,allBlocks(inx)});
    end
    result = ft;
    end

    For more information on how to format check results, see Define Custom Model Advisor Checks.

    Input Arguments

    collapse all

    ModelAdvisor.FormatTemplate object, specified as a handle to the template object.

    Table row entries, specified as a cell array of character vectors or cell array of objects. The order of the items in the cell array determines which column the item is in.

    Example: {'Item 1', 'Item 2'}