NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Member
ars_xx
Posts: 6
0 Kudos

how to read TDMS file in MATLAB

I am having trouble reading TDMS file in MATLAB. I have download NI matlab example code for it. I get it to work for their TDM file but it is not working properly for my file. I have 3 groups of channel. But even though I specified the channel group which I want to read it is reading the wrong channel group and MATLAB code is spitting an error of  "undefined function or variable chanvals".

 

The channel group I want to read contains 16 channels. The data size is 0.8 million x 16. First column is time and rest of the columns are strain. At the end of the time I want to read this TDMS file in MATLAB and plot time vs. strain for all the channels, time on x-axis and strain on y-axis. Is the existing NI code capable of doing this or I have to modify the code to do this operation.

 

Any help is really appreciated.

 

Thank you very much.

Member
Logan_H.
Posts: 90
0 Kudos

Re: how to read TDMS file in MATLAB

Hey there,

 

Which NI example are you using to do this? The latest example that I have found was this which works with both TDMS 1.0 & 2.0 files.

 

Additionally, is the TDMS file created by your software or from LabVIEW? I found a few threads that may be of interest to you here and here.

 

Logan H

National Instruments
Applications Engineer
Member
ars_xx
Posts: 6
0 Kudos

Re: how to read TDMS file in MATLAB

This is the same example, I have been using. But no success yet and my files were created in Labview. I am using cRIO from NI as my DAQ. I am wondering is their any user guide to use this example? because I have been going between MATLAB code (ReaderFile.m) and header file (nilibddc_m.h) and modified bunch of times to get it work but no luck yet.

 

I have modified header file with my file, channel group and channels properties but it does not work. I would greatly appreciate if their exist any user friendly poineters to use NI MATLAB code to read TDMS file.

 

Thanks so much for your reply.

 

 

Member
Logan_H.
Posts: 90
0 Kudos

Re: how to read TDMS file in MATLAB

I have plenty of experience working in LabVIEW and with TDMS however very little in using it in other software. I have downloaded the example code on this end but since I don't have your software installed on my machine, there is not a ton I can do in walking you through it. However, I understand this is a very helpful newsgroup for that environment.

 

Since you said you modified the header, to make sure everything is in line prior to entering other program, this is a good resource on the TDMS file structure.

 

Logan H

National Instruments
Applications Engineer
Member
Sappster
Posts: 178
0 Kudos

Re: how to read TDMS file in MATLAB

Hi Ars_xx,

 

Are you still experiencing trouble reading your TDMS file. The error you mentioned makes me believe it is most likely a datatype mismatch. You can view the contents of the variable type when you obtain that error to view the detected datatype of the values in the tdms file. You will want to ensure that this datatype mirrors the datatype used in line 165 and line 169 of the ReadFile.m example.

 

Let me know if I can be of more assistance.

Sappster