Example Code

Reading TDM/TDMS Files with The MathWorks, Inc. MATLAB® Software

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Operating System

  • Windows

    Other

  • MATLAB

Code and Documents

Attachment

Description

The TDM MATLAB Example shows how to read TDM and TDMS files from within the MATLAB® from THE MathWorks software environment.

 

Supported Features:

  • Consists of TDM C DLL and adapted C-header file (nilibddc_m.h) to be used in conjunction with MATLAB®

FILE EXTENSION: *.TDM; *.TDMS

DIRECTION: Read / ----

LAST CHANGE: September 2020

 

 

How to Use

  1. Download the attached zip file referenced in this document titled MATLAB-TDM-Example.zip.
  2. Unzip the downloaded zip file MATLAB-TDM-Example.zip
  3. Examine the folder “Examples”

If you copy the TDM dll and the header file into "C:\test\", you must specify the location in your m-script like this:

 

examplePath = 'C:\test';
hfile = [examplePath '\nilibddc_m.h'];
loadlibrary([examplePath '\nilibddc'], hfile);

 

Keep in mind that this provides only the capability to read TDM/TDMS files with the MATLAB® software environment and that the example has been tested with MATLAB® Versions R2007a, R2007b, and R2008a.  It is expected that the example will work with earlier versions as well.

 

Important: Please follow the licensing and installation instructions in the files license.rtf and Readme.txt which are part of this download.

 

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

 

 

Related Links

 

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
brajan337
Member
Member
on

Hello.

I have a question. How can I get  the sampling frequency or the sampling period from my .tdms file?

PS. Great job. It is very useful.Capture1.PNG

SN_engineer
Member
Member
on

I am looking for a utility to import TDMS files into Matlab that works out of the box. This code may be useful to developers, but definitely isn't useful for my purposes. For starters, it deletes all of the useful data after it plots it. Secondly, it doesn't import all of the data I need, like the sampling frequency and channel start time. I tried using the nilibddc.chm included in the package to look up the properties to add to the code, but it's just a list of help topics with no help pages attached. I don't know how else to describe it, there's an index of help pages and they're all blank. When I was setting up my experiments, I used TDMS because the page explaining TDMS includes the phrase: "NI has developed an example demonstrating how to read TDM and TDMS files from within the MATLAB® from The MathWorks software environment." which links to this article. If I had known it was going to be this much of a pain, I would have used another logging method. For all of the money we are paying for Labview and Matlab, I really expect better. Don't advertise that you have a utility to import data into Matlab if it doesn't work out of the box.