Main Content

tdmsread

Read data from TDMS-file

Description

example

data = tdmsread(tdmsfile) retrieves data from the specified TDMS-file and returns a cell array of tables. Each element of the cell array is a table corresponding to a channel group.

data = tdmsread(tdmsfile,Name=Value) uses name-value pairs to filter the data reading and specify output format.

Examples

collapse all

Read data from a specified TDMS-file. You can determine which channels are read, and what format the result has.

Read all data from a TDMS-file into a table.

data = tdmsread("airlinesmall.tdms");

Read a subset of the variables in a TDMS-file into MATLAB as a timetable. Use the variable ArrTime in the TDMS-file as the time vector of the output timetable.

data = tdmsread("airlinesmall.tdms", ...
           ChannelGroupName = "Airline", ...
           ChannelNames = ["ArrTime" "FlightNum" "ArrDelay"], ...
           RowTimes = "ArrTime");

Read the channel data into a timetable with a specified start time and step duration.

data = tdmsread("airlinesmall.tdms", ...
           ChannelGroupName = "Airline", ...
           ChannelNames = ["ArrTime" "FlightNum" "ArrDelay"], ...
           TimeStep = seconds(0.01), StartTime = seconds(30));

Input Arguments

collapse all

TDMS file name, specified as a string.

For local files, use a full or relative path that contains a file name and extension. You also can specify a file on the MATLAB path.

For Internet files, specify the URL. For example, to read a remote file from the Amazon S3 cloud:

data = tdmsread("s3://bucketname/path_to_file/data.tdms");

Example: "airlinesmall.tdms"

Data Types: char | string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: ChannelGroupName="Torque",ChannelNames="Torque1"

Supported name-value pairs are:

Channel group containing the channels to read from, specified as a string or character vector.

Example: "Torque"

Data Types: string | char

Names of channels to read, specified as a string, string array, character vector, or cell array of character vectors. The channels must be in the channel group specified by ChannelGroupName.

Example: ["Torque1" "Torque2"]

Data Types: char | string | cell

Times associated with rows of the table, specified as a selected time channel name, a datetime vector, or a duration vector. Specifying this option causes the function to output a cell array of timetables. Each time element labels a row in the output timetable.

Example: duration(seconds([1:1000]/1000))

Data Types: datetime | duration | string

Start time of the output timetable, specified as a scalar datetime or duration indicating the time of the first data record in the timetable.

Example: StartTime=seconds(60)

Data Types: datetime | duration

Sample rate of the output timetable, specified as a positive scalar double indicating samples per second.

Example: SampleRate=1000

Data Types: double

Time step of the output timetable, specified as a scalar duration or calendarDuration indicating the time span between data records.

Example: TimeStep=seconds(0.01)

Data Types: duration | calendarDuration

Output Arguments

collapse all

Output data, returned as a cell array of tables or timetables with data records from the TDMS-file. Each element of the cell array is a table or timetable for a channel group. The cell array index corresponds to the channel group number.

When the start time for the first sample is 0 and the sample times are relative to that (duration), the sample times returned to the timetable are based on seconds since the epoch in the local time zone equivalent to 01/01/1904 00:00:00.00 UTC (using the Gregorian calendar and ignoring leap seconds). For more information, see TDMS File Format Internal Structure.

Limitations

  • TDMS functions are supported on Windows® platforms only.

Version History

Introduced in R2022a

See Also

Functions