Contenuto principale

addRow

Add row to table in Model Advisor analysis results

Description

addRow(ftObj,rowEntries) inserts a new row, containing the data specified in rowEntries at the end of the table represented 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.

example

Examples

collapse all

This example demonstrates how to create a table in Model Advisor, set its title and columns, and add rows containing block information from a model.

Use ModelAdvisor.FormatTemplate to create a formatting template object of type 'TableTemplate'.

ft = ModelAdvisor.FormatTemplate("TableTemplate");

Specify the title for your table.

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

Before adding any rows, set the column titles.

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

Open the model vdp:

openExample("vdp");
ans = logical
   1

Find all blocks in the model and add them as rows to the table.

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

You can use this logic in a check callback function, for example in your sl_customization file.

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

Input Arguments

collapse all

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

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"}

Version History

Introduced in R2009a