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 belonging to a Model block referencing a model

  • A masked subsystem parameter

  • A model workspace variable

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.

A Parameter Writer block must be located inside either a conditionally executed subsystem or an Initialize Function, Reinitialize Function, or Reset Function block. A Parameter Writer block cannot be placed inside a Simulink® function. If a Parameter Writer block is not located inside an Initialize Function, Reinitialize Function, or Reset Function block, then the Parameter Writer block must be in the same task as the block whose parameter is directly written by the Parameter Writer block, which could be a Model block or a masked subsystem block.

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).

Note

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

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.

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™.