Output input from previous time step
Simulink / Discrete
HDL Coder / Discrete
The内存block holds and delays its input by one major integration time step. When placed in an iterator subsystem, it holds and delays its input by one iteration. This block accepts continuous and discrete signals. The block accepts one input and generates one output. Each signal can be a scalar, vector, matrix, or N-D array. If the input is non-scalar, the block holds and delays all elements of the input by the same time step.
You specify the block output for the first time step using theInitial conditionparameter. Careful selection of this parameter can minimize unwanted output behavior. However, you cannot specify the sample time. This block’s sample time depends on the type of solver used, or you can specify to inherit it. TheInherit sample timeparameter determines whether sample time is inherited or based on the solver.
Tip
Avoid using the Memory block when both these conditions are true:
Your model uses the variable-step solverode15s
orode113
.
The input to the block changes during simulation.
When the Memory block inherits a discrete sample time, the block is analogous to theUnit Delayblock. However, the Memory block does not support state logging. If logging the final state is necessary, use aUnit Delayblock instead.
The内存,Unit Delay, andZero-Order Holdblocks provide similar functionality but have different capabilities. Also, the purpose of each block is different.
This table shows recommended usage for each block.
Block | Purpose of the Block | Reference Examples |
---|---|---|
Unit Delay | Implement a delay using a discrete sample time that you specify. The block accepts and outputs signals with a discrete sample time. |
|
内存 | Implement a delay by one major integration time step. Ideally, the block accepts continuous (or fixed in minor time step) signals and outputs a signal that is fixed in minor time step. |
|
Zero-Order Hold | Convert an input signal with a continuous sample time to an output signal with a discrete sample time. |
Each block has the following capabilities.
Capability | 内存 | Unit Delay | Zero-Order Hold |
---|---|---|---|
Specification of initial condition | Yes | Yes | No, because the block output at time t = 0 must match the input value. |
Specification of sample time | No, because the block can only inherit sample time from the driving block or the solver used for the entire model. | Yes | Yes |
Support for frame-based signals | No | Yes | Yes |
Support for state logging | No | Yes | No |
The内存block is a bus-capable block. The input can be a virtual or nonvirtual bus signal subject to the following restrictions:
Initial conditionmust be zero, a nonzero scalar, or a finite numeric structure.
IfInitial conditionis zero or a structure, and you specify aState name, the input cannot be a virtual bus.
IfInitial conditionis a nonzero scalar, you cannot specify aState name.
For information about specifying an initial condition structure, seeSpecify Initial Conditions for Bus Elements.
All signals in a nonvirtual bus input to a内存block must have the same sample time, even if the elements of the associated bus object specify inherited sample times. You can use aRate Transitionblock to change the sample time of an individual signal, or of all signals in a bus. SeeModify Sample Times for Nonvirtual BusesandBus-Capable Blocksfor more information.
You can use an array of buses as an input signal to a内存block. You can specify theInitial conditionparameter with:
The value0
. In this case, all the individual signals in the array of buses use the initial value0
.
An array of structures that specifies an initial condition for each of the individual signals in the array of buses.
A single scalar structure that specifies an initial condition for each of the elements that the bus type defines. Use this technique to specify the same initial conditions for each of the buses in the array.
For details about defining and using an array of buses, seeGroup Nonvirtual Buses in Arrays of Buses.
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|