| Data Acquisition Toolbox | Search  Help Desk |
| daqread | Examples See Also |
Read a Data Acquisition Toolbox (.daq) file.
Syntax
data = daqread('file');
data = daqread('file','P1, V1, 'P2', V2,...);
[data, time] = daqread(...);
[data, time, abstime] = daqread(...);
[data, time, abstime, events] = daqread(...);
[data, time, abstime, events, daqinfo] = daqread(...);
daqinfo = daqread('file','info');
Description
data = daqread('file') reads all the data from file and returns an m-by-n data matrix, data, where m is the number of samples and n is the number of channels. If data from multiple triggers is read, each trigger is separated by a NaN and m is increased by the number of triggers.
data = daqread('file','P1', V1, 'P2', V2,...) reads the specified data from file and returns an m-by-n matrix to data, where m is the number of samples and n is the number of channels. If data from multiple triggers is read, each trigger is separated by a NaN and m is increased by the number of triggers. The amount of data returned and the format of that data is specified with property name/property value pairs. The available properties and values are given below.Samples, Time, and Triggers properties are mutually exclusive. The Time property must be specified as a datenum value. This allows event times to be used as the range.
[data, time] = daqread(...) returns sample-time pairs.
[data, time, abstime] = daqread(...) returns sample-time pairs and the absolute time of the first trigger. abstime is returned as a datenum value and can be converted to a string using datestr.
[data, time, abstime, events] = daqread(...) returns sample-time pairs, the absolute time of the first trigger, and a log of events. abstime is returned as a datenum value and can be converted to a string using datestr. events contains the appropriate event structure based on the samples, triggers or time specified. The entire event log is returned only if samples, time, and triggers are not specified.
[data, time, abstime, events, daqinfo] = daqread(...) returns sample-time pairs, the absolute time, the event log, and the structure daqinfo, which 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 events structure is identical to the information returned by daqinfo.ObjInfo.EventLog. The entire event log is returned only if samples, time, and triggers are not specified.
daqinfo = daqread('file','info') returns the structure daqinfo, which contains two fields: ObjInfo and HwInfo. ObjInfo is a structure containing property/value pairs and HwInfo is a structure containing hardware information. The entire event log is returned to daqinfo.ObjInfo.EventLog.
Note:
daq) files are created by specifying a value for the LogFileName property and setting LoggingMode to Disk or Disk&Memory.
Example
National Instruments
Suppose you configure the analog input objectai for a National Instruments board as shown below. The object acquires one second of data for four channels, and saves the data to the output file data.daq.
ai = analoginput('nidaq','1');
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 the file data.daq
[data, time] = daqread('data.daq');
data.daq
data = daqread('data.daq', 'Samples', [500 1000]);
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 return the absolute time of the first logged event (the start event) and convert the time from a datenum value to a string
event1_time = event_data{1}.Time;
event1_time_str = datestr(event1_time);
See Also
Properties
LogFileName, LoggingMode, LogToDiskMode