Main Content

addParameter

Class: Simulink.Mask
Package: Simulink

Add a parameter to a mask

Syntax

p = Simulink.Mask.get(blockName)
p.addParameter(Name,Value)

Description

p = Simulink.Mask.get(blockName) gets the mask on the block specified by blockName as a mask object.

p.addParameter(Name,Value) appends a parameter to the mask. If you do not specify name–value pairs as arguments with this command, Simulink® generates name for the mask parameter with control type set to edit.

Input Arguments

expand all

blockName

The handle to the block or the path to the block inside the model.

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.

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

Type of control that is used to specify the value of this parameter. The permitted values are: edit, checkbox, popup, combobox, listbox, radiobutton, slider, dial, spinbox, unit, textarea, breakpoint, customtable, tree, unit, min, max.

The options that are displayed within a popup control or in a promoted parameter. This field is a cell array.

The name of the mask parameter. This name is assigned to the mask workspace variable created for this parameter.

Text that identifies the parameter on the Mask Parameters dialog box.

The default value of the mask parameter in the Mask Parameters dialog box. Type specific; depends on the Type of the parameter

Option to specify whether parameter must be evaluated.

Option to specify whether parameter is tunable.

Option to specify whether user can set parameter value.

Option to set whether mask parameter is hidden or visible to the user.

Container for MATLAB code that executes when user makes a change in the Mask Parameters dialog box.

Option to specify a container for the child parameters. The permitted values are the names of 'panel', 'group', and 'tab'.

Examples

Add Popup Parameter

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);
p= Simulink.Mask.get(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;