Write to a block state
Simulink / Signal Routing
The State Writer block sets the state of a supported state owner block.
State Writer blocks can write state to these state owner blocks:
Discrete Transfer Fcn
Discrete FIR Filter
Outport of conditional subsystem blocks such as Enabled Subsystem, Triggered Subsystem, and Function-Call Subsystem
S-Function with multiple discrete states
To configure an S-Function block as a state owner block, each data type work
vector must be declared as a discrete state vector using
You can determine whether a block is a supported state owner block by the value of
IsStateOwnerBlock parameter. The
blkis a block name or handle, returns
'on'if the block is a supported state owner block and
To add a State Reader or State Writer block to your
model, right-click on a state owner block and drag to an empty portion of the
Simulink® canvas. When you release, a menu will appear. Select
State Reader Block or
Create State Writer
After you create a State Reader or State Writer block, a badge appears above the state owner block, and the name of the state owner block appears next to the State Reader or State Writer block.
A State Reader or State Writer block cannot remain in the same system as its state owner block. After you create a State Reader or State Writer block, cut and paste it to move it to the desired location within the model hierarchy.
Alternatively, you can add a State Reader or State Writer block to your model from the Simulink Library Browser, then set the State owner block parameter from the block parameters dialog.
When you create a library block with a State Reader or State Writer block, you must also include the corresponding state owner block in the library block.
You can select a State Reader or State Writer block or a corresponding state owner block to highlight blocks related to it. To show a related block in an open diagram or new tab, pause on the ellipsis that appears after selection. Then, select Related Blocks from the action bar. When multiple blocks correspond to the selected block, a list of related blocks opens. You can filter the list of related blocks by entering a search term in the text box. After you select a related block from the list, window focus goes to the open diagram or new tab that shows the related block.
In— State value
State value written to a state owner block.
When writing to a state owner block with an input scalar, the scalar value is expanded to match the dimension of the state. All elements of the state are set to the same value.
State owner block— Name of state owner block
Name of state owner block whose state this block is writing. To change the state owner block, select a block from the State Owner Selector Tree.
If the name of a state owner block contains a slash
/), the slash appears as two slashes
//) in the State Writer block
parameters dialog. This notation distinguishes the slash in the block
name itself from slashes that separate names at different levels of the
|Type: character vector|