MATLAB: How to use a For Iterator subsystem to model a For Each subsystem that uses a delay block

simulink

When using a Unit Delay block on a signal within a For Each subsystem, the delayed values of a signal are preserved for each iteration. However, this is not the case when a For Iterator subsystem is used. Instead, the delayed value from a previous iteration is stored. How can I model the behavior of the For Each subsystem with a For Iterator subsystem block?

Best Answer

You can use the Assignment and Selector blocks and place a Unit Delay block on a signal that contains an array of values. Each delayed value will then be preserved in the same way that is automatically done with the For Each block. See attached models to see an example of this modeling technique.