Main Content

addParameter

Class: Simulink.Mask
Package: Simulink

Add a parameter to a mask

Syntax

maskobj.addParameter(Name,Value)

Description

maskobj.addParameter(Name,Value) appends a parameter to the mask. If you do not specify any name-value arguments, the software generates name for the mask parameter with the control type set to edit.

To get the mask object for a block named blockName, use this command.

maskObj = Simulink.Mask.get('BlockName')

Input Arguments

expand all

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: p.addParameter('Type','popup',...'TypeOptions',{'Red' 'Blue' 'Green'},'Evaluate','off');

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Type of parameter, specified as character vector.

Data Types: char | string

The options that are displayed within a popup or combobox or listbox parameter, specified as a cell array.

Data Types: cell

The name of the mask parameter, specified as a character vector. This name is assigned to the mask workspace variable created for this parameter.

Data Types: char | string

Display name for the mask parameter, specified as a character vector. This name appears as the label associated with the parameter on the mask dialog.

Data Types: char | string

The default value of the mask parameter in the Mask Parameters dialog. Type specific, depends on the Type of the parameter, specified as a character vector.

Data Types: char | string

Option to evaluate mask parameter, specified as a logical.

Data Types: logical

Option to change the mask parameter during simulation, specified as logical value.

Data Types: logical

Option to enable the mask parameter in the mask dialog, specified as a logical.

Data Types: logical

Option to show the mask parameter in the mask dialog, specified as a logical.

Data Types: logical

Callback code for the mask parameter, specified as a character vector. The callback code executes when a user changes the parameter value in the mask dialog box.

Data Types: char

Option to enable tooltips for the mask parameter, specified as a logical value.

Data Types: logical

Alternative name for the mask parameter is specified as character vector.

Data Types: char | string

Layout options for the parameter in the mask dialog, specified as a character vector. The location of the parameter in the mask dialog such as the row location, prompt location is specified. Additionally horizontal stretch or shrink of the mask parameter is also specified.

Data Types: char | string

Examples

expand all

Step 1: Get mask as an object using a masked block’s path.

new_system('paramexample');
add_block('built-in/subsystem','paramexample/subsystem');
save_system;
open_system('paramexample');
p= Simulink.Mask.create(gcb);

Step 2: Add a parameter to the mask without specifying name–value pairs for parameter attributes.

p.addParameter;

Step 3: Add a mask parameter of type popup that cannot be evaluated.

p.addParameter('Type','popup','TypeOptions',{'Red' 'Blue' 'Green'},'Evaluate','off');
save_system;

Version History

Introduced in R2014a