In Simulink
®
, you can create your own block libraries as a way to reuse the
functionality of blocks or subsystems in one or more models. Similarly, you can reuse a
set of Stateflow
®
algorithms by encapsulating the functionality in a chart library.
As with other Simulink block libraries, you can specialize each instance of chart library blocks
in your model to use different data types, sample times, and other properties. Library
instances that inherit the same properties can reuse generated code.
For more information about Simulink block libraries, see
Custom Libraries
(Simulink)
.
Create Specialized Chart Libraries for Large-Scale Modeling
Add Stateflow charts with polymorphic logic to a Simulink model.
Polymorphic logic is logic that can process data with different
properties, such as type, size, and complexity.
Configure the charts to inherit the properties you want to
specialize.
In Simulink, create a library model. In the
Simulation
tab, select
New
>
Library
Copy or drag the charts into a library model.
Customize Properties of Library Blocks
You can customize instances of Stateflow library blocks by allowing them to inherit any of the following
properties from Simulink.
Property
Inherits by Default?
How to Specify Inheritance
Type
Yes
Set the data type property to
Inherit: Same as
Simulink
.
Size
Yes
Set the data size property to
-1
.
Complexity
Yes
Set the data complexity property to
Inherited
.
Limit range
No
Specify minimum and maximum values as Simulink parameters. For example, if minimum value =
aParam
and maximum value =
aParam
+ 3, different instances of a
Stateflow library block can resolve to different
aParam
parameters defined in their parent
mask subsystems.
Initial value
Depends on scope
For local data, temporary data, and outputs, specify
initial values as Simulink parameters. Other data always inherits the
initial value:
Parameters inherit the initial value from the
associated parameter in the parent mask
subsystem.
Inputs inherit the initial value from the
Simulink input signal.
Data store memory inherits the initial value
from the Simulink data store to which it is
bound.
Different library instances inherit different data type
override modes from their ancestors in the model
hierarchy.
Sample time (block)
Yes
Set the block sample time property to
-1
.
Limitations of Library Charts
Events parented by a library chart are invalid. The Stateflow parser flags such events as errors.
To include a linked library chart within another library chart, the
two library charts must be in separate libraries.
To include a linked library chart within a Simulink subsystem, first save the library chart within a subsystem
and place that library subsystem in the Simulink subsystem.
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
MathWorks
Accelerating the pace of engineering and science
MathWorks es el líder en el desarrollo de software de cálculo matemático para ingenieros