addRow
向模型顾问分析结果中添加表行
说明
addRow(
向格式模板对象 ftObj
,rowEntries
)ftObj
所指定表的末尾添加包含 rowEntries
内容的表行。如果没有向表中添加数据,模型顾问就不会在结果中显示该表。
注意
在向表中添加表行之前,必须使用 setColTitles
方法指定列标题。
函数 addRow
用来格式化通过 Simulink® Check™ 得到的模型顾问分析结果中的表。有关详细信息,请参阅 Simulink Check。
有关如何在 MATLAB® 中使用表的信息,请参阅创建表并为其分配数据。
示例
向表模板对象添加表行
创建一个 type
为 'TableTemplate'
的模型顾问格式化模板对象 ft
,并向表中添加一个表行。
使用 ModelAdvisor.FormatTemplate
创建一个 type
为 'TableTemplate'
的模型顾问格式模板 ft
。
ft = ModelAdvisor.FormatTemplate('TableTemplate');
指定表标题。
setTableTitle(ft,{'Blocks in Model'});
在向表中添加表行之前,必须指定列标题。
setColTitles(ft,{'Index','Block Name'});
通过输入以下命令打开模型 vdp
:
openExample('vdp')
找到当前系统 vdp
中的模块,并将它们添加到表中。
allBlocks = find_system('vdp'); for inx = 2:length(allBlocks) addRow(ft,{inx-1,allBlocks(inx)}); end
在 sl_customization
文件的检查回调函数中使用 addRow
来格式化模型顾问分析结果。
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
有关如何格式化检查结果的详细信息,请参阅定义自定义模型顾问检查。
输入参数
ftObj
— 模板对象
模板对象句柄
ModelAdvisor.FormatTemplate
对象,指定为模板对象的句柄。
rowEntries
— 表行内容
字符向量元胞数组 | 对象的元胞数组
表行项,指定为字符向量元胞数组或对象元胞数组。元胞数组中各项的顺序确定该项位于哪一列。
示例: {'Item 1', 'Item 2'}
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)