Data Acquisition Toolbox
  Function/Property:
    Search    Help Desk 

Example: Logging and Retrieving Information

This section illustrates how to log information to a disk file and then return the logged information to MATLAB using various calls to daqread.

In the example below, a sound card is configured for stereo acquisition, data is logged to memory and to a disk file, four triggers are issued, and two seconds of data is collected for each trigger at a sample rate of 8 kHz. All the logged data is then read from the file as sample-time pairs.

Initialization: Create the analog input object ai for a sound card. The available adaptors are found with daqhwinfo.

Configuration: Add two hardware channels to ai, define a two second acquisition for each trigger, set the trigger to repeat three times, and log data and events to the file file00.daq.

Execution: Start ai, wait for ai to stop running, and extract all the data stored in the engine as sample-time pairs.

Termination: Plot the data and delete ai.

Returning Data Based on Samples

You can return data based on samples using the Samples property. The daqread call shown below returns samples 1000 to 2000 for both sound card channels.

Returning Data Based on Channels

You can return data based on channels using the Channels property. The daqread call shown below returns samples 1000 to 2000 for the second sound card channel.

Alternatively, you can specify the channel name.

Returning Data Based on Triggers

You can return data based on triggers using the Triggers property. The daqread call shown below returns all the data associated with the second and third triggers for both sound card channels.

Returning Data Based on Time

You can return data based on time using the Time property. The values specified for Time must be datenum values.

For this example, the first 25% of the data acquired for the first trigger will be returned. The first Time value corresponds to the first trigger event and can be found with the EventLog property.

The second Time value is constructed by adding one-half second to the first Time value. Note that when a number is added to a datenum value, it must be normalized as shown below.

You can now return the first 25% of the data acquired for the first trigger.

Returning Event, Object, and Hardware Information

As shown on page 4-65, you can return event, object, and hardware, information by specifying the appropriate output arguments to daqread. To return all event information, you must return all the logged data.

If part of the data is returned, then only the events associated with the requested data are returned.

Alternatively, you can return the entire event log as well as object and hardware information by including 'info' as an input argument to daqread.



[ Previous | Help Desk | Next ]