Main Content

insertParameter

Class: Simulink.Mask
Namespace: Simulink

Create and insert mask parameter at a specified index

Since R2024a

Syntax

maskObj.insertParameter(index)
maskObj.insertParameter(___,index,Name=Value)

Description

maskObj.insertParameter(index) creates and inserts a mask parameter of type edit at the position specified by index.

maskObj.insertParameter(___,index,Name=Value) creates and inserts a mask parameter at the position specified by index.

Input Arguments

expand all

Mask object for the masked subsystem.

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

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

Position at which to insert the mask parameter, specified as a numeric. The index starts from 1. Specify a value greater than or equal to 1.

Example: 3

Data Types: double

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: Type = 'edit',Name = 'Parameter1'

Type of mask parameter, specified as character vector.

Data Types: string

Type options of the parameter, specified as a cell array. This argument applies only if the parameter is one of the following types:

  • Popup

  • Combo box

  • List box

Data Types: cell

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

Note

If you create a mask parameter with a duplicate name, the software displays a warning but still creates the mask parameter with a different name.

Data Types: string | char

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

Data Types: char | string

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

Data Types: char | string

Option to evaluate the mask parameter, specified as a logical. The available options are:

  • on — The expression provided in the value property is evaluated.

  • off — The expression provided in the value property is not evaluated.

Data Types: string

Option to change the mask parameter during simulation, specified as a character vector or string. The available options are:

  • off — You cannot change mask parameter values during simulation in this mode.

  • on — You can change the mask parameter value during simulation. Each time you make a change the model is compiled.

  • run-to-run — If the mask parameter is set to run-to-run in Fast Restart mode, the value can be changed between runs. The model is not recompiled to reflect the value in simulation results.

Data Types: string

Option to save the mask parameter value in the model file, specified as a logical.

  • on — The mask parameter value is saved in the model file.

  • off — The mask parameter value is not saved in the model file.

Data Types: string

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

Data Types: string

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

Data Types: char

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

Data Types: char

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

Data Types: char

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

Data Types: char

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 | string

Alternative name for the mask parameter, specified as a character vector or string.

Data Types: char | string

Option to associate a tunable variable with the popup or radio button parameters, specified as a character vector or string. This variable appears in the generated code.

Data Types: char | string

Layout options for the parameter in the mask dialog, specified as objects. Use this parameter to specify the location of the parameter, such as the row and prompt placement in the mask dialog. Additionally, you can also control the horizontal stretch or shrink of the mask parameter.

Examples

expand all

Create a mask object maskobj on the Subsystem. Insert an edit box with name Speed on the Subsystem at a specific position.

new_system('insert_parameter');
add_block('built-in/subsystem','insert_parameter/subsystem');
save_system;
open_system('insert_parameter');
maskObj = Simulink.Mask.create('insert_parameter/subsystem');
insertParameter(maskObj,1,Type = 'edit',Name ='Speed')
ans = 
  MaskParameter with properties:

              Type: 'edit'
       TypeOptions: {0x1 cell}
              Name: 'Speed'
            Prompt: ''
             Value: '[]'
    ConstraintName: ''
          Evaluate: 'on'
           Tunable: 'on'
         NeverSave: 'off'
            Hidden: 'off'
          ReadOnly: 'off'
           Enabled: 'on'
           Visible: 'on'
       ShowTooltip: 'on'
          Callback: ''
             Alias: ''
      VariableName: ''
     DialogControl: [1x1 Simulink.dialog.parameter.Edit]

Version History

Introduced in R2024a