以编程方式查看 DataTypeStr
您可以在 MATLAB® 命令行窗口中使用 Simulink.Mask.get 命令来查看为模块封装指定的数据类型值。MATLAB 使用预定义的命名法在命令行中表示数据类型信息。
此示例说明如何以编程方式查看示例模型封装参数的 DataTypeStr 参数。
maskobj = Simulink.Mask.get(gcb)
maskobj =
Mask with properties:
Type: ''
Description: ''
Help: ''
Initialization: ''
SelfModifiable: 'off'
Display: ''
IconFrame: 'on'
IconOpaque: 'opaque'
RunInitForIconRedraw: 'off'
IconRotate: 'none'
PortRotate: 'default'
IconUnits: 'autoscale'
Parameters: [1×4 Simulink.MaskParameter]
BaseMask: [0×0 Simulink.Mask]
ParameterConstraints: [0×0 Simulink.Mask.Constraints]
BlockConstraintRules: [0×0 Simulink.Mask.BlockConstraints]
ConstraintParamAssociator: [0×0 Simulink.Mask.ConstraintParamAssociator]
maskobj.getParameter('DataTypeStrParameter')
ans =
MaskParameter with properties:
Type: 'unidt({a=4|2|3|1}{i=Inherit: auto|Inherit: Inherit via internal rule}{b=double|single})'
TypeOptions: {0×1 cell}
Name: 'DataTypeStrParameter'
Prompt: 'Output data type'
Value: 'Inherit: auto'
Evaluate: 'on'
Tunable: 'off'
NeverSave: 'off'
Hidden: 'off'
ReadOnly: 'off'
Enabled: 'on'
Visible: 'on'
ShowTooltip: 'on'
Callback: ''
Alias: ''
结果显示为 DataTypeStr 参数定义的属性。此示例定义指定类型选项的命名法:
Type: 'unidt({a=4|2|3|1}{i=Inherit: auto|Inherit: Inherit via internal
rule}{b=double|single})'
此处,Type 显示为 DataTypeStr 参数指定的值,并具有以下定义:
a 定义 Associations,其对应值为 4、2、3、1。这些值是参数的索引编号,依次代表 DataTypeStr、Min、Max 和 Edit 参数。
i 将 Inherit rules 及其对应的值定义为 Inherit: Same as first input。
b 将 Built-in types 及其对应的值定义为 double 和 single。