daqread
Read Data Acquisition Toolbox (.daq)
file
Syntax
data = daqread('filename')
[data,time] = daqread(...)
[data,time,abstime] = daqread(...)
[data,time,abstime,events] = daqread(...)
[data,time,abstime,events,daqinfo]
= daqread(...)
data = daqread(...,'Param1',
Val1,...)
daqinfo = daqread('filename','info')
Description
data = daqread('filename')
reads all the data from the Data Acquisition Toolbox™ (.daq) file specified
by filename.
daqread returns
data, an
m-by-n data
matrix, where m is the number of
samples and n is the number of
channels. If data includes data from
multiple triggers, the data from each trigger is
separated by a NaN. If you set the
OutputFormat property to
tscollection,
daqread returns a time series
collection object. See below for more
information.
[data,time] = daqread(...)
returns time/value pairs. time is an
m-by-1 vector, the same length
as data, that contains the relative
time for each sample. Relative time is measured with
respect to the first trigger that occurs.
[data,time,abstime] = daqread(...)
returns the absolute time of the first trigger.
abstime is returned as a
clock vector.
[data,time,abstime,events] = daqread(...)
returns a log of events. events is a
structure containing event information. If you specify
either theSamples,
Time, or
Triggers parameters (see
below), the events structure contains only the
specified events.
[data,time,abstime,events,daqinfo]
= daqread(...)
returns a structure, daqinfo, that
contains two fields: ObjInfo and
HwInfo.
ObjInfo is a structure
containing property name/property value pairs and
HwInfo is a structure
containing hardware information. The entire event log
is returned to
daqinfo.ObjInfo.EventLog.
data = daqread(...,
specifies the amount of data returned and the format of
the data, using the following parameters.'Param1',
Val1,...)
Parameter | Description |
|---|---|
| Specify the sample range. |
| Specify the relative time range. |
| Specify the trigger range. |
| Specify the channel range. Channel names can be specified as a cell array. |
| Specify the data format as
|
| Specify the time format as
|
| Specify the output format as
|
The Samples, Time, and
Triggers properties are mutually exclusive; that is, you can
specify only one of them in a function call.
daqinfo = daqread('filename','info')
returns metadata from the file in the
daqinfo structure, without
incurring the overhead of reading the data from the
file as well. The daqinfo structure
contains two fields:
daqinfo.ObjInfoa structure containing parameter/value pairs for the data acquisition object used to create the file,
filename. Note: TheUserDataproperty value is not restored.daqinfo.HwInfoa structure containing hardware information. The entire event log is returned to
daqinfo.ObjInfo.EventLog.
Examples
This example shows how to read data that was saved to the log
file data.daq in an earlier release. This logging was achieved by
specifying the logging properties of an analoginput object. Use
daqread to retrieve the data and other acquisition related
information.
Read all the sample-time pairs from
data.daq:
[data,time] = daqread('data.daq');Read samples 500 to 1000 for all channels from
data.daq:
data = daqread('data.daq','Samples',[500 1000]);
Read only samples 1000 to 2000 of channel indices 2, 4, and 7 in
native format from the file
data.daq:
data = daqread('data.daq', 'Samples', [1000 2000],... 'Channels', [2 4 7], 'DataFormat', 'native');
Read only the data that represents the first and second triggers
on all channels from the file
data.daq:
[data,time] = daqread('data.daq', 'Triggers', [1 2]);
Obtain the channel property information from
data.daq:
daqinfo = daqread('data.daq','info'); chaninfo = daqinfo.ObjInfo.Channel;
Obtain a list of event types and event data contained in
data.daq:
daqinfo = daqread('data.daq','info'); events = daqinfo.ObjInfo.EventLog; event_type = {events.Type}; event_data = {events.Data};
Read all the data from the file data.daq and
return it as a time series collection object:
data = daqread('data.daq','OutputFormat','tscollection');
Tips
More About .daq Files
If data from multiple triggers is read, then the size of the resulting data array is increased by the number of triggers issued, because each trigger is separated by a
NaN.ObjInfo.EventLogalways contains the entire event log regardless of the value specified bySamples,Time, orTriggers.The
UserDataproperty value is not restored when you return device object (ObjInfo) information.When reading a
.daqfile, thedaqreadfunction does not return property values that were specified as a cell array.
More About Time Series Collection Object Returned
When OutputFormat is set to
tscollection,
daqread returns a time series
collection object. This time series collection
object contains an absolute time series object for
each channel in the file. The following describes
how daqread sets some of the
properties of the time series collection object
and the time series objects.
The
timeproperty of the time series collection object is set to the value of theInitialTriggerTimeproperty specified in the file.The
nameproperty of each time series object is set to the value of theNameproperty of a channel in the file. If this name cannot be used as a time series object name,daqreadsets the name to'Channel'with theHwChannelproperty of the channel appended.The value of the
Unitsproperty of the time series object depends on the value of theDataFormatparameter. If theDataFormatparameter is set to'double',daqreadsets theDataInfoproperty of each time series object in the collection to the value of theUnitsproperty of the corresponding channel in the file. If theDataFormatparameter is set to'native',daqreadsets theUnitsproperty to'native'.Each time series object will have
tsdata.eventobjects attached corresponding to the log of events associated with the channel.