Documentation on the behavior of the Buffer block when used in an enabled subsystem can be found at:
Documentation -> Buffer (DSP System Toolbox) -> Behavior in Enabled Subsystems
Here is additional information on the Buffer block.
When operating in Sample Based mode, the Buffer block creates framed data from the sampled data that is passed into it. The placement of a given sample depends on both the Buffer Overlap parameter and the Output Buffer Size parameter. Thus, knowing the sample time of the input port and the time a particular sample arrives, you can determine where in the output frame that sample will be.
For example, imagine a Buffer block has 0 as a Buffer Overlap, an Output Buffer Size of 3, and the input port of the Buffer block has a sample time of 0.1. This means that every 0.3 seconds, the Buffer block will output the previous 3 samples. Thus, the output from the Buffer block will change at simulation times of 0.3, 0.6, 0.9, etc. If a sample arrives at simulation time 0.8, it will be in the 3rd row of the buffer, underneath the sample from 0.6 and 0.7.
This mapping from simulation time to buffer placement holds true even if the Buffer block is in an enabled subsystem. While it is true that the enabled subsystem will prevent data from entering or leaving the subsystem, it does not effect where in the buffer the Buffer block will place incoming data. This can lead to results that are not intuitive.
In summary, the following things are important to remember when using a Buffer block in an enabled subsystem:
1) The output to the Buffer block (inside enabled subsystem) is only updated when an entire new frame is gathered.
2) Data is only sent to or received from an enabled subsystem when the subsystem is enabled.
3) So, the output of the enabled sub-system with the buffer block is only present when the buffer is full and the enabled subsystem has a high pulse. Please note, by default the setting of the enabled subsystem 'Enable' and 'Output' blocks are to set 'held' the previous data.
With respect to the 'simple_example.mdl' model attached, as the sample time for the buffer block and buffer (inside Enabled Subsystem) is 1 sec, the output gets updated every 1 sec in the simulation. For the enabled subsystem case, the first time output gets updated is at 3.0 secs, because that is the first time 'Enabled Subsystem' along with 'Buffer' block can output a frame. The next frame gets captured from 3-4 secs [as enabled] but it outputs that only at 5.0 secs. Prior to 5.0 sec and after 3.0 sec it keeps outputting the 1st frame captured [due to held setting by default in enabled subsystem]. In order to view these outputs, please change the stop time from 2.0 -> 3.0, 4.0, 5.0 secs.
If this behavior of the Buffer block is undesirable, consider using a Delay Line block instead. In certain cases, it might also be possible to move the buffering/unbuffering logic outside of the enabled subsystem.
Best Answer