How Can I Stream Data from LabVIEW to Mathworks, Inc. Matlab®

Updated Aug 3, 2023

Reported In

Software

  • LabVIEW

Issue Details

I would like to continulously stream data from LabVIEW to Mathworks, Inc. Matlab® for processing. What is the best way to do this?

Solution

If you are using a Mathworks, Inc. Matlab® supported DAQ device and would like to connect your DAQ device directly to Mathworks, Inc. Matlab®:
  • Use the Mathworks, Inc. Matlab® Data Acquisition Toolbox Support Package for NI-DAQmx.
If you want to acquire or generate a single data set in LabVIEW then process the data in Mathworks, Inc. Matlab®:
  • Acquire or generate your data in LabVIEW.
  • Using the Write to Measurement File Express VI or using the methods shown in the LabVIEW Example Finder, write your data to a Mathworks, Inc. Matlab® compatible file type.
  • Once your VI has finished running and has closed the file containing the data, open the file in your Mathworks, Inc. Matlab® program.
If you want to continuously generate data in LabVIEW and process the data in Mathworks, Inc. Matlab® on-the-fly:
  • This behavior is best accomplished using a Producer/Consumer Loop.
  • The Producer Loop should be used to acquire or generate your data.
  • The Consumer Loop should be used to repeatedly generate a file, open the file, write a chunk of data to the file, and close the file.
  • The size of the chunks of data written to each file can be set programmatically or it can be based on user input.
  • Files that have been written and closed can then be processed on-the-fly by Mathworks, Inc. Matlab® while the LabVIEW VI continues to run and generate new files.

Additional Information

Note: It is not recommended to open the generated files in Mathworks, Inc. Matlab® before the LabVIEW VI has finished writing and has closed the file.