How can I break a saved signal into pieces according to when the subsystem that produces it is reset?

1 view (last 30 days)
I have a "To Workspace" block within an enabled subsystem. I would like to this signal into sections according to when the subsystem is enabled.
For instance, if the subsystem is enabled twice, I want to be able to distinguish the samples from the first time it was enabled, from those that came from the second time.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
One way to do this is to create another signal that indicates at which times the subsystem has been newly-enabled, and record this signal using another "To Workspace" block. The two attached files provide an example:
In the Simulink model (example.mdl, attached), there is an enabled subsystem that has two "To Workspace" blocks, one for the original saved signal (var_out), and one for a counter (counter_out).
When the subsystem is reset, the counter signal falls back to zero, since the “States when enabling” parameter for the subsystem set to “reset”. This allows one to write a MATLAB file that compares consecutive values of the counter signal to determine when the subsystem has been reset: if the counter decreases in value, the subsystem has been reset.
In the example MATLAB file (sort-signals.m, attached), the signal is separated into different elements of a cell array.
If, in your subsystem, you do not wish the other states to be reset, you can build another subsystem for the counter that works off the same control signal, but whose “States when enabling” parameter is set to “reset”.

More Answers (0)

Categories

Find more on Schedule Model Components in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!