主要内容

本页采用了机器翻译。点击此处可查看英文原文。

ModelAdvisor.InputParameter 类

命名空间: ModelAdvisor
超类:

向自定义检查添加输入参数

描述

ModelAdvisor.InputParameter 类的实例指定自定义检查在分析模型时使用的输入参数。在模型顾问窗口中访问输入参数。

创建

描述

input_param = ModelAdvisor.InputParameter 创建输入参数对象 input_param 的句柄。

注意

您必须在检查定义中包含输入参数定义。

方法

setColSpan指定输入参数的列数
setRowSpan为输入参数指定行

属性

Description输入参数描述
Entries下拉列表项
Name输入参数名称
Type输入参数类型
Value输入参数的值

复制语义

句柄。要了解这对类的使用有何影响,请参阅 MATLAB® 编程基础文档中的复制对象

示例

全部折叠

您可以使用输入参数在运行自定义检查之前请求输入。

通过使用 ModelAdvisor.InputParameter 类定义输入参数。

您可以使用方法 setInputParametersLayoutGridsetRowSpansetColSpan 来指定模型顾问中输入参数的布局。

您必须在自定义检查定义函数中包含输入参数定义。您必须为要添加到自定义检查中的每个输入参数定义此类的一个实例。以下示例是检查定义函数中的一段代码。如果没有完整的检查定义函数,该示例不会按所示方式执行。

rec = ModelAdvisor.Check('com.mathworks.sample.Check1');
rec.setInputParametersLayoutGrid([3 2]);
% define input parameters
inputParam1 = ModelAdvisor.InputParameter;
inputParam1.Name = 'Skip font checks.';
inputParam1.Type = 'Bool';
inputParam1.Value = false;
inputParam1.Description = 'sample tooltip';
inputParam1.setRowSpan([1 1]);
inputParam1.setColSpan([1 1]);
inputParam2 = ModelAdvisor.InputParameter;
inputParam2.Name = 'Standard font size';
inputParam2.Value='12';
inputParam2.Type='String';
inputParam2.Description='sample tooltip';
inputParam2.setRowSpan([2 2]);
inputParam2.setColSpan([1 1]);
inputParam3 = ModelAdvisor.InputParameter;
inputParam3.Name='Valid font';
inputParam3.Type='Combobox';
inputParam3.Description='sample tooltip';
inputParam3.Entries={'Arial', 'Arial Black'};
inputParam3.setRowSpan([2 2]);
inputParam3.setColSpan([2 2]);
rec.setInputParameters({inputParam1,inputParam2,inputParam3});