This example shows how to use the Simulink Real-Time template to create a 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.
To create this model from the Simulink start page, in the MATLAB 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. On the Real-Time tab, click Run on Target. Or, use the
rtwbuild command and the
Run the real-time application and log data by using the
Open the Simulation Data Inspector by double-clicking the Simulation Data Inspector icon on the Gain block output signal or by using the