Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

read

Read channel data from MDF file

Syntax

data = read(mdfObj,chanGroupIndex,chanName)
data = read(mdfObj,chanGroupIndex,chanName,startPosition)
data = read(mdfObj,chanGroupIndex,chanName,startPosition,endPosition)
data = read(mdfObj,chanGroupIndex,chanName,startPosition,endPosition,'OutputFormat',fmtType)
[data,time] = read(mdfObj,chanGroupIndex,chanName,startPosition,endPosition,'OutputFormat','Vector')

Description

example

data = read(mdfObj,chanGroupIndex,chanName) reads all data for the specified channel from the MDF file identified by the MDF file object mdfObj.

example

data = read(mdfObj,chanGroupIndex,chanName,startPosition) reads data from the position specified by startPosition.

example

data = read(mdfObj,chanGroupIndex,chanName,startPosition,endPosition) reads data for the range specified from startPosition to endPosition.

example

data = read(mdfObj,chanGroupIndex,chanName,startPosition,endPosition,'OutputFormat',fmtType) returns data with the specified output format.

example

[data,time] = read(mdfObj,chanGroupIndex,chanName,startPosition,endPosition,'OutputFormat','Vector') returns two vectors of channel data and corresponding timestamps.

Examples

collapse all

Read all available data from the MDF file for specified channels.

mdfObj = mdf('MDFFile.mf4');
data = read(mdfObj,1,{'Channel1','Channel2'});

Read a range of data from the MDF file using indexing for startPosition and endPosition to specify the data range.

mdfObj = mdf('MDFFile.mf4');
data = read(mdfObj,1,{'Channel1','Channel2'},1,10);

Read a range of data from the MDF file using time values for startPosition and endPosition to specify the data range.

mdfObj = mdf('MDFFile.mf4');
data = read(mdfObj,1,{'Channel1','Channel2'},seconds(5.5),seconds(7.3));

Read all available data from the MDF file, returning data and time vectors.

mdfObj = mdf('MDFFile.mf4');
[data,time] = read(mdfObj,1,'Channel1','OutputFormat','Vector');

Read all available data from the MDF file, returning time series data.

mdfObj = mdf('MDFFile.mf4');
data = read(mdfObj,1,'Channel1','OutputFormat','TimeSeries');

Input Arguments

collapse all

MDF file, specified as an MDF file object.

Example: mdf('MDFFile.mf4')

Index of channel group, specified as a numeric value that identifies the channel group from which to read.

Example: 1

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Name of channel, specified as a character vector, string, or array. chanName identifies the name of a channel in the channel group. Use a cell array of character vectors or array of string to identify multiple channels.

Example: 'Channel1'

Data Types: char | string | cell

First position of channel data, specified as a numeric value or duration. The startPosition option specifies the first position from which to read channel data. Provide a numeric value to specify an index position; use a duration to specify a time position. If only startPosition is provided without the endPosition option, the data value at that location is returned. When used with endPosition to specify a range, the function returns data from the startPosition (inclusive) to the endPosition (noninclusive).

Example: 1

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | duration

Last position of channel data range, specified as a numeric value or duration. The endPosition option specifies the last position for reading a range of channel data. Provide both the startPosition and endPosition to specify retrieval of a range of data. The function returns up to but not including endPosition when reading a range. Provide a numeric value to specify an index position; use a duration to specify a time position.

Example: 1000

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | duration

Format for output data, specified as a character vector or string. This option formats the output according to the following table.

OutputFormatDescription
'Timetable'

Return a timetable from one or more channels into one output variable. This is the only format that supports reading from multiple channels at the same time. (Default.)

Note: The timetable format includes columns for the MDF channels. Because the column titles must be valid MATLAB® identifiers, they might not be exactly the same as those values in the MDF object ChannelNames property. The column headers are derived from the property using the function matlab.lang.makeValidName. The original channel names are available in the VariableDescriptions property of the timetable object.

'Vector'Return a vector of numeric data values, and optionally a vector of time values from one channel. Use one output variable to return only data, or two output variables to return both data and time vectors.
'TimeSeries'Return a time series of data from one channel.

Example: 'Vector'

Data Types: char | string

Output Arguments

collapse all

Channel data, returned as vector of doubles, a time series, or a timetable, according to the 'OutputFormat' option setting.

Channel data times, returned as a vector of double elements. The time vector is returned only when the 'OutputFormat' is set to 'Vector'.

See Also

Functions

Introduced in R2016b

Was this topic helpful?