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
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
Pause the stimulation of a specific inport or all inports by using the
Stop the stimulation of a specific inport or all inports by using the
Get the status of stimulation of inports by using the
Load data to specific inports by using the
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:
Open Model and Map Inport to Wave Data
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'); open_system(model); load('slrt_ex_inport_square.mat'); waveform = square; set_param(model,'ExternalInput','waveform'); set_param(model,'LoadExternalInput','on'); set_param(model,'StopTime','Inf');
Build Model and Download Real-Time Application
Build, download, and execute the real-time application.
evalc('slbuild(model)'); tg = slrealtime('TargetPC1'); load(tg,model);
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.