Main Content

Control and Update Stimulation of Inports to Real-Time Application

You can stream data to the inports of a real-time application on a target computer by using the Target.Stimulation object and functions. The functions enables you to control inport stimulation for individual or all inports and monitor stimulation status.

To load data to the inports, create a time series object by using, for example the timeseries function. Load the object into the inport. Do not pause or stop the stimulation of inports before or during the stimulation. A pause or stop generates a stimulation error.

To control or monitor stimulation of inports in a real-time application:

  • Start the stimulation of a specific inport or all inports by using the start function.

  • Pause the stimulation of a specific inport or all inports by using the pause function.

  • Stop the stimulation of a specific inport or all inports by using the stop function.

  • Get the status of stimulation of inports by using the getStatus function.

  • Load data to specific inports by using the reloadData function.

Stimulate Root Inport by Using MATLAB Language

This example shows how to stimulate root inports in a model by using the Stimulation object and related functions:

  • start

  • stop

  • getStatus

  • reloadData

  • pause

Create Target Object and Connect

Create a Target object for the default target computer and connect to the target computer. In the Command Window, type:

tg = slrealtime;

Open Model and Map Inport to Wave Data

Open model slrt_ex_osc_inport. Save the model to a working folder. Map the inport to use square wave data. For inport In1, interpolated is off.

model = ('slrt_ex_osc_inport');
waveform = square;
modelSTF = getSTFName(tg);

Build Model and Download Real-Time Application

Build, download, and execute the real-time application.


Stimulate Root Inport Data

Start root inport stimulation of inports 1. Open Scope block and observe results.


Pause root inport stimulation of inport 1.


Stop and start the stimulation of inport 1.


Check the status of stimulation of the inports.


Create a time-series object to load data to an inport.

sampleTime = 0.1;
endTime = 10;
numberOfSamples = endTime * 1/sampleTime + 1;
timeVector = (0:numberOfSamples) * sampleTime;
u = timeseries(timeVector*10,timeVector);

Object u is created for 10 seconds. Load it to the inport 1. Stimulation of an inport should be stopped before loading data.


Stop real-time application and close all.


See Also