Communication Documentation

This documentation shows how to perform udp, tcpip and serial communication on a PC using MATLAB and Simulink.


The function and block that you use depends on whether you need to generate code out of your communication code. If you are running MATLAB and Simulink on a PC without generating code out of the communication methods, use the Instrument Control Toolbox. If you are generating C code or an executable out of MATLAB or Simulink code, use the DSP System Toolbox.

Run MATLAB Function and Simulink Model directly on a desktop computer

If you are planning on running MATLAB Functions and Simulink models directly on a desktop computer, and therefore you do not need to generate code out of the MATLAB Functions and Simulink Models, use the Instrument Controol Toolbox's communication methods. Although the methods are not supported for code generation, the Instrument Control Toolbox supports more protocols (i.e. Serial, UDP, TCP/IP).

The following examples will show how to use these communication methods:

Instrument Control Toolbox Communication

As of R2015a, the Robotics System Toolbox has provided MATLAB and Simulink ROS Communication functionality. The toolbox has many examples which show how to use the ROS protocol. Here is one of them:

Exchanging Data with ROS Publishers and Subscribers

Generate an executable out of a MATLAB Function or Simulink Model

If you need to generate code out of your MATLAB or Simulink code (i.e. create an executable), you will need to use the DSP System Toolbox's UDP Send and Receive functionality.

Although UDP is the only communication protocol supported, the DSP System Toolbo'x UDP Send and Receive are supported for code generation, allowing the user to generate executables.

The following examples will show how to use these communication methods:

DSP System Toolbox Communication

Simulink models can be deployed to a Linux ROS computer to perform communication with ROS messages. MATLAB ROS functionality is not supported for code generation. The method to generate an executable out of a Simulink model with ROS is different from other documentation in this guide. See the following example to see how this is performed:

Generating a standalone ROS node from Simulink