How to Use MATLAB® in LabVIEW NXG

Updated Mar 31, 2020

Reported In

Software

  • LabVIEW NXG

Other

MathWorks MATLAB®

Issue Details

I want to use MATLAB code in LabVIEW NXG. I know that LabVIEW supports MATLAB script node. It seems there is no MATLAB Script node or MathScript Node in LabVIEW NXG.

How can I integrate MATLAB code in my G dataflow LabVIEW NXG project?

Solution

There is a new built-in feature named Interface for MATLAB from LabVIEW NXG 3.0. An Interface for MATLAB (.mli) is a document in which you define calls to a MATLAB file (.m or .mlx) in your G dataflow application. MATLAB files can be either functions or scripts. NI recommends that you format MATLAB programs into functions because functions perform better than scripts and offer a clean programming model. 

In an Interface for MATLAB, you create interface nodes that map to arguments in a MATLAB function or variables in a MATLAB script.

Visual representations of interface nodes appear on the Project Item » Software palette on the diagram. You can place and wire interface nodes in your application. When you execute the application, the Interface for MATLAB invokes MATLAB, which calls the MATLAB file. Input data passes from the diagram to MATLAB, and data returns from MATLAB to the diagram.
 

Search within the programming environment to access the following installed examples:
  • Interface for MATLAB Fundamentals
  • Interface for MATLAB Working with nD Arrays
  • Interface for MATLAB Working with Structures
  • MATLAB User Defined Function
  • MATLAB Monte Carlo Calculation
  • Prime Number Calculation
MATLAB® is a registered trademark of The MathWorks, Inc.

Additional Information

For detail steps to call MATLAB® functions and scripts, please refer to this manual link. Calling MATLAB® Functions and Scripts