Archived: Interfacing LabVIEW Communications to MATLAB® Software

NI does not actively maintain this document.

This content provides support for older products and technology, so you may notice outdated links or obsolete information about operating systems or other relevant products.


To enable complete reuse of your existing MATLAB® code, LabVIEW Communications System Design Suite (LabVIEW Communications) introduces a feature called the Interface for MATLAB. Designers who are trying to develop a wireless prototype can point to their MATLAB function or script on their computer and connect it to code running on a Windows processor in LabVIEW Communications. The Interface for MATLAB has full support for MATLAB toolboxes, as it calls into a licensed copy of the MATLAB software installed on the same computer as LabVIEW Communications. This enables design teams to immediately connect their MATLAB code to over-the-air signals using NI Software Defined Radios, exchange information like filter coefficients and configurations during an experiment, and rapidly implement real-time, FPGA-based prototypes.

Interfacing with MATLAB

The Interface for MATLAB is similar to other interfaces in LabVIEW Communications that call non-LabVIEW code, such as the Shared Library Interface for shared libraries (.dll, .so) and External IP for VHDL and Verilog. A user can create a new Interface for MATLAB from their LabVIEW project, and from there point to a MATLAB file on disc, select whether it is a function or a script, and configure the inputs and outputs to LabVIEW Communications. Numerics, multi-dimensional arrays of scalars, clusters/structures, and arrays of clusters are among the data types that can be passed directly between LabVIEW Communications and MATLAB.


In this example, a 5-MHz, LTE-like OFDM modulator written in MATLAB software will be interfaced with LabVIEW Communications and connected with an NI USRP (Figure 1 & 2).


Fig 1. A 5-MHz, LTE-like OFDM modulator written in MATLAB software will be interfaced with LabVIEW Communications running on a processor and connected with an NI USRP.


Fig 2. Interface document for MATLAB, pointing to the function ofdm_tx.m with input and output y configured. 


Once the Interface for MATLAB is configured, it can be dropped onto the diagram of a VI – which contains the source code for a user’s prototype - connected to other algorithms and hardware I/O APIs, and executed on a Windows processor. In Figure 3, a stream of data packets are connected to the input of the OFDM modulator and the output is connected to the NI USRP API for over-the-air transmission. If there are any errors in how LabVIEW Communications is interfacing with MATLAB, the user can see MATLAB errors, which will be passed to their VI.


Fig 3. The Interface node for MATLAB pointing to the function ofdm_tx.m, dropped onto the Diagram and connected to the NI USRP API for over-the-air transmission.


Co-Development and Debugging

Using the Interface for MATLAB, a user can debug or modify their MATLAB code while interfacing with LabVIEW Communications in parallel to ensure rapid integration and troubleshooting of the whole prototype. Because LabVIEW Communications is calling into a copy of MATLAB on the same computer and opening a specific session of MATLAB, the MATLAB Command Line will open in the background. A user can use the open command to open the full MATLAB Editor and insert breakpoints for debugging. When the VI interfacing with MATLAB is run, the code will hit the breakpoint in MATLAB, allowing the user to debug using the full suite of debugging tools available, including the ability to pause the MATLAB code and step line by line through their code (Figure 4).


Figure 4: When the LabVIEW Communications VI is run, execution will break at the breakpoint on line 18 in MATLAB.


Next Steps

Download the evaluation to try the Interface for MATLAB in LabVIEW Communications

Learn more about LabVIEW Communications


MATLAB® is a registered trademark of The MathWorks, Inc.

Was this information helpful?