MATLAB: How to use global signals across nonvirtual subsystem boundaries in Simulink 7.5 (R2010a)

simulink

I would like to use global signals in Simulink, i.e. signals that I can pass from any level of my model to any other level of the model. The "goto" and "from" tags to not work across nonvirtual subsystem boundary, i.e., the boundary of an atomic, conditionally executed, or function-call subsystem or a model reference.

Best Answer

You can achieve this by using Data Store Read/Write blocks, together with Simulink.Signal workspace objects (this is what makes the data stores "global" across nonvirtual subsystem boundaries). See the attached models for an example of this. Here, "XandY" references "ModelX" and "ModelY" to show how data stores can indeed cross nonvirtual boundaries.
Note that you should not use a Data Store Memory block anywhere in these models in order to have the global signal functionality. Only Data Store Read and Write blocks should be used, and the corresponding Simulink.Signal objects should be declared in the base workspace. For instance, the attached models require objects "A" and "B" in the base workspace, which can be instantiated as follows:
A=Simulink.Signal;
A.DataType='double';
A.Dimensions=1;
A.Complexity='real';
A.SamplingMode='Sample based';
A.InitialValue='0';
B=Simulink.Signal;
B.DataType='double';
B.Dimensions=1;
B.Complexity='real';
B.SamplingMode='Sample based';
B.InitialValue='0';
Please refer to the link below for more information about a nonvirtual system block in Simulink:
<http://www.mathworks.com/help/releases/R2011a/toolbox/simulink/slref/subsystem.html>