Calling the MATLAB® Software from LabVIEW

LabVIEW 2018 Help

Edition Date: March 2018
Part Number: 371361R-01
View Product Info

DOWNLOAD (Windows Only)

LabVIEW 2015 Help
LabVIEW 2016 Help
LabVIEW 2017 Help
LabVIEW 2018 Help
LabVIEW 2019 Help

You must have a licensed copy of the MATLAB® software version 6.5 or later installed to use MATLAB script nodes because the script nodes invoke the MATLAB software script server to execute scripts written in the MATLAB language syntax. The MATLAB script nodes are available only on Windows.

Complete the following steps to create and run a VI that uses a script you wrote in the MATLAB language syntax.

  1. Add a MATLAB script node to the block diagram.

Note  You can create MATLAB script nodes only in the LabVIEW Full and Professional Development Systems. If a VI contains a MATLAB script node, you can run the VI in all LabVIEW packages.
  1. Use the Operating or Labeling tool to enter the following script in the MATLAB script node:



  2. Add an output to the MATLAB script node and create an indicator for the output.
    1. Right-click the right side of the MATLAB script node frame and select Add Output from the shortcut menu.
    2. Enter a in the output terminal to add an output for the a variable in the script.
    3. Verify the data type of the output terminal. In the MATLAB script node, the default data type for any new input or output is Real. Right-click the a output and select Choose Data Type»2-D Array of Real from the shortcut menu.
    4. Right-click the a output terminal and select Create»Indicator from the shortcut menu to create a 2D array of numeric indicators labeled 2-D Array of Real.
  3. Right-click the error out output terminal and select Create»Indicator from the shortcut menu to create an error out indicator labeled error out.
  4. Resize the 2-D Array of Real front panel indicator so you can see the numbers the script generates when the VI runs.
  5. Run the VI. LabVIEW invokes the MATLAB software script server, creates a matrix of random values, displays the matrix in the MATLAB software, plots that information to a graph, and displays the values that make up the matrix in the 2-D Array of Real front panel indicator.
  6. (Optional) Debug your script written in the MATLAB language syntax.

You can display a scroll bar within a MATLAB script node.

Note  A script inside a MATLAB script node behaves as it does in the MATLAB software environment.


Not Helpful