Main Content

Parameter Writer

Write to block parameter or model workspace variable

  • Library:
  • Simulink / Signal Routing

  • Parameter Writer block icon

Description

The Parameter Writer block changes block parameter values by writing to one of the following:

  • A parameter of a block that is tunable during simulation

  • An instance parameter that belongs to a Model block that references a model

  • A masked subsystem parameter

  • A model workspace variable

A block with a parameter that can be written by a Parameter Writer block is called a parameter owner block. For the Parameter Writer block to find the supported parameters of a parameter owner block, the supported parameters must be enabled.

Use the Parameter Writer block with the Initialize Function, Reinitialize Function, and Reset Function blocks to respond to events. For example, an event could be reading the value from a hardware sensor and then updating a block parameter based on the sensor value.

For more information about using the Parameter Writer block, see Initialize and Reset Parameter Values.

When a Parameter Writer block is not in an Initialize Function, Reinitialize Function, or Reset Function block, the Parameter Writer block must be in a conditionally executed subsystem, such as an enabled subsystem or a function-call subsystem, and in the same task as either:

  • The block whose parameter is directly written by the Parameter Writer block, which could be a Model block or a masked Subsystem block

  • The block whose parameter is indirectly written through a model workspace variable

To write to a model workspace variable, mask parameter, or Model block instance parameter with a Parameter Writer block, the model workspace variable, mask parameter, or Model block instance parameter must be used by a parameter owner block or C MEX S-function with run-time tunable parameters.

For a Parameter Writer block in a masked subsystem, the Parameter Writer block and corresponding parameter owner block must have the same immediate parent masked subsystem.

When a Parameter Writer block writes to an instance parameter with storage class set to Model default, the code generator uses the default configuration for Model parameter arguments when generating code for the parameter. See Specify Instance-Specific Parameter Values for Reusable Referenced Model (Simulink Coder).

When you create a library block with a Parameter Writer block, you must also include the corresponding parameter owner block in the library block.

Identify Parameter Owner Blocks

You can determine whether a block is a supported parameter owner block by the value of the IsParamOwnerBlock block parameter. Use the get_param function with the block name or handle, blk, and the IsParamOwnerBlock block parameter.

get_param(blk,'IsParamOwnerBlock')

The function returns 'on' if the block is a supported parameter owner block and 'off' otherwise.

A Parameter Writer block and the parameter owner block of the value that the block writes constitute a set of related blocks. You can select a Parameter Writer block to highlight the related parameter owner block or vice versa. When a related block is highlighted, blocks in the current model that contain the related block are also highlighted. For example, an Initialize Function block is highlighted when it contains a Parameter Writer block that is related to the selected block. The blocks that are highlighted in the model canvas are also highlighted in the miniature map.

To show a related block in an open diagram or new tab, pause on the ellipsis that appears after selection. Then, select the Related Blocks button from the action bar. Window focus goes to the open diagram or new tab that shows the related block.

Limitations

A Parameter Writer block cannot be placed in a Simulink® function.

Ports

Input

expand all

Parameter value written by the block.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus

Parameters

expand all

Select this check box to write to a model workspace variable, as specified in Model workspace parameter name.

Clear this check box to write to a tunable block parameter, model instance parameter, or masked subsystem parameter, as specified in Parameter owner block.

Programmatic Use

Block Parameter: AccessWorkspaceVariable
Type: character vector
Value: 'off' | 'on'
Default: 'off'

Name of workspace variable whose value this block writes.

Dependencies

To enable this parameter, select the Access model workspace parameter check box.

Programmatic Use

Block Parameter: WorkspaceVariableName
Type: character vector | string scalar
Default: ''

Parameter owner block and the name of the parameter whose value this block writes. To change the parameter owner block or the parameter, select a block and parameter from the Parameter Owner Selector Tree.

Note

If the name of a parameter owner block contains a slash (/), the slash appears as two slashes (//) in the Parameter Writer Block Parameters dialog box. This notation distinguishes the slash in the block name itself from slashes that separate names at different levels of the model hierarchy.

Dependencies

To enable this parameter, clear the Access model workspace parameter check box.

Programmatic Use

Block Parameter: ParameterOwnerBlock
Type: character vector | string scalar
Value: '' | 'ModelPath/BlockName'
Default: ''

Programmatic Use

Block Parameter: ParameterName
Type: character vector | string scalar
Default: ''

Block Characteristics

Data Types

Boolean | bus | double | enumerated | fixed point | integer | single

Direct Feedthrough

no

Multidimensional Signals

yes

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.