This topic describes how to reference a rate-based model in a test mode, and then add periodic function-call event ports to the test model for simulation.
Testing a rate-based model includes referencing the model from a Model block in a test model, adding periodic function-call event ports to the Model block, and then connecting function-calls to the ports.
Create a new Simulink model.
Add a Model block and open the block parameters dialog box.
In the Model name box, enter the file name for the rate-based model.
Select the Schedule rates check box.
Periodic function-call event ports are added to the Model block with the Sample times you specified for the Inport blocks connected to the Subsystem blocks.
Specify the execution rate using function-call initiators (Function-Call Generator blocks or Stateflow® charts). The function-call events and scheduling of the events are located outside of the Model block referencing the rate-based model.
In this example, add Function-Call Generator blocks. Open the block dialog box for the blocks and specify Sample time.
Subsystems or referenced models in a rate-based model with the same sample time must have a common rate initiator. This requirement includes periodic scheduled subsystems and event-driven Function-Call Subsystem blocks with the same rate.
Use a fixed-step solver for simulation. Set the configuration parameters
Fixed-step, Solver to
auto, and Fixed-step size to
Simulate the behavior of a rate-based model from the test model.
Run a simulation. Some common compile and run-time errors are cause by:
A periodic event port that is not connected to a function-call initiator with the same specified sample time.
A scheduled Inport block (Sample time parameter set to a value) in the referenced component model that does not specify one of the periodic function-call event port rates (sample times specified in the Port discrete rates table).
Observe the behavior of the component model. Open the Scope block.