Main Content

Target and Application Objects

The Simulink® Real-Time™ software uses a Target object to represent a target computer and an Application object to represent a real-time application. To run and control real-time applications on the target computer, use the object functions.

An understanding of the Target and Application object properties and functions helps you to control and test your real-time application on the target computer.

A Target object on the development computer represents the interface to a real-time application and the RTOS on the target computer. To run and control the real-time application, use Target objects.

When you change a Target object property on the development computer, information is exchanged between the target computer and the real-time application.

To create a Target object for the default target computer, in the MATLAB® Command Window, type:

tg = slrealtime

A Target object has properties and functions specific to that object. The real-time application object functions enables you to control a real-time application on the target computer from the development computer. You enter real-time application object functions in the MATLAB Command Window on the development computer or you can use MATLAB code scripts. To access the help for these functions from the command line, use the syntax:

doc slrealtime/function_name

For example, to get help on the load function, type:

doc slrealtime/load

To get a list of all the functions for the Target object, use the methods function. For example, to get the functions for Target object tg, type:


If you want to control the real-time application from the target computer, use target computer commands (see Control Real-Time Application at Target Computer Command Line).

Control Real-Time Application by Using Objects

You can create a real-time application and control it by using Target and Application objects

  1. Open a model and build a real-time application. This example uses the slrt_ex_osc model.

  2. Create Target and Application objects to represent the target computer and the real-time application.

    tg = slrealtime('TargetPC1');
    app = slrealtime.Application('slrt_ex_osc');
  3. Load the real-time application on the target computer by using the Target object.

  4. Set the Target object stoptime property for the real-time application.

  5. Get the Application object options property values from the real-time application.

    ans =
  6. Start the real-time application by using the Target object.

  7. Stop the real-time application by using the Target object.


Use Real-Time Application Object Functions

To run Target object and Application functions, use the function_name(target_object, argument_list) syntax.

Unlike properties, for which partial but unambiguous names are permitted, you must enter function names in full, in lowercase. For example, to start a real-time application on target computer tg, in the MATLAB Command Window, type:

tg = slrealtime;

See Also


Related Topics