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



Code and Documents



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®


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.



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