MATLAB: How to model a system in which can collect simulation data from enabled time points of an Enabled Subsystem in Simulink 7.8 (R2012a)

simulink

I am using an Enabled Subsystem in my model such that the following behavior can be modeled:
– When Enabled, just collect data point coming from an input
– When Disabled, make available the array with the collected data point from the previous enable time points

Best Answer

To implement the system as described, i.e. to save the values from a previous time points during the 'Enable' state during the 'Disable' state of an 'Enabled Subsytem', please refer to an example model attached to this solution.
The example highlights the following technique:
- Use an input to ENABLE/DISABLE the 'Enabled Subsystem'
- Use a periodic input value to pass to the output via an 'Enabled Subsystem'
- The implementation logic uses a delay block to save the previous time inputs using an assisgnment block. The main idea in this example is to pre-allocate the array size with '0'. Using a counter block, to count the signal index, we can assign to an output vector the value from 'Enable' time points using a SELECTOR block.