Parameter Writer
Write to block parameter or model workspace variable
- Library:
Simulink / Signal Routing
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
Parameters
Model Examples
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Extended Capabilities
See Also
Initialize Function | Reinitialize Function | Reset Function | Terminate Function | Event Listener | State Reader | State Writer | Model