This example shows how to use the Simulink Real-Time template for a new Simulink model. Starting from the model template for Simulink Real-Time provides a new model that has configuration parameters set up for building a real-time application.
To see the Simulink Real-Time commands for each operation in this example, view the example code.
Create a new Simulink model from the Simulink Real-Time model template.
To create this model from the Simulink start page, in the Command Window, type:
Select the Simulink Real-Time template from the start page, and create the
exampleSlrtApp model. Or, in the Command Window, use the
The Simulink Real-Time model template contains a gain block that connects an inport to an outport. To make this model produce more interesting data to view on a target scope and to view with the simulation data inspector (SDI), add these blocks and connections. You can use the UI for these steps or use the script commands shown:
Add a signal generator by using the
add_block command. Use the
set_param command to set its Amplitude parameter value to 4 and set its Frequency parameter value to 400.
Add a target scope by using the
Remove the connections between the Gain block, inport, and outport by using the
Connect the signal generator to the gain block input by using the
Connect the gain block output to the target scope by using the
Mark the Gain block output for data logging by using the
You are ready to build the real-time application, run it on the target computer, and view the logged data with these steps:
Make sure that the development computer has a connection to the target computer.
Build the model and download the real-time application to the target computer by clicking the Build button or by using the
Run the real-time application and log data by using the
Open SDI by double-clicking the simulation data inspector icon on the Gain block output signal or by using the