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(...,'Param1', Val1,...) specifies the amount of data returned and the format of the data, using the following parameters.

Parameter

Description

Samples

Specify the sample range.

Time

Specify the relative time range.

Triggers

Specify the trigger range.

Channels

Specify the channel range. Channel names can be specified as a cell array.

DataFormat

Specify the data format as doubles (default) or native.

TimeFormat

Specify the time format as vector (default) or matrix.

OutputFormat

Specify the output format as matrix (the default) or tscollection. When you specify tscollection, daqread only returns data.

The Samples, Time, and Triggers properties are mutually exclusive; that is, either Samples, Triggers or Time can be defined at once.

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.ObjInfo

a structure containing parameter/value pairs for the data acquisition object used to create the file, filename. Note: The UserData property value is not restored.

daqinfo.HwInfo

a structure containing hardware information. The entire event log is returned to daqinfo.ObjInfo.EventLog.

Remarks

More About .daq Files

More About Time Series Collection Object Returned

When OutputFormat is set to tscollection, daqread returns a time series collection object. This times 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 times series collection object and the time series objects.

If daqread returns data from multiple triggers, the data from each trigger is separated by a NaN in the time series data. This increases the length of data and time vectors in the time series object by the number of triggers.

Examples

Use Data Acquisition Toolbox to acquire data. The analog input object, ai, acquires one second of data for four channels, and saves the data to the output file data.daq.

ai = analoginput('nidaq','Dev1');
chans = addchannel(ai,0:3);
set(ai,'SampleRate',1000)
ActualRate = get(ai,'SampleRate');
set(ai,'SamplesPerTrigger, ActualRate)
set(ai,'LoggingMode','Disk&Memory')
set(ai,'LogFileName','data.daq')
start(ai)

After the data has been collected and saved to a disk file, you can retrieve the data and other acquisition-related information using daqread. To read all the sample-time pairs from data.daq:

[data,time] = daqread('data.daq');

To read samples 500 to 1000 for all channels from data.daq:

data = daqread('data.daq','Samples',[500 1000]);

To 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');

To read only the data which represents the first and second triggers on all channels from the file, data.daq:

[data, time] = daqread('data.daq', 'Triggers', [1 2]);

To obtain the channel property information from data.daq:

daqinfo = daqread('data.daq','info');
chaninfo = daqinfo.ObjInfo.Channel;

To obtain a list of event types and event data contained by data.daq:

daqinfo = daqread('data.daq','info');
events = daqinfo.ObjInfo.EventLog;
event_type = {events.Type};
event_data = {events.Data};

To read all the data from the file data.daq and return it as a time series collection object:

data = daqread('data.daq','OutputFormat','tscollection');

See Also

Functions

timeseries, tscollection

For more information about using this function, see the Data Acquisition Toolbox documentation.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS