Data Acquisition Toolbox    

Example: Logging and Retrieving Information

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

A sound card is configured for stereo acquisition, data is logged to memory and to a disk file, four triggers are issued, and 2 seconds of data are collected for each trigger at a sampling rate of 8 kHz. You can run this example by typing daqdoc8_1 at the MATLAB command line.

  1. Create a device object -- Create the analog input object ai for a sound card. The installed adaptors and hardware IDs are found with daqhwinfo.
  2. Add channels -- Add two hardware channels to ai.
  3. Configure property values -- Define a 2 second acquisition for each trigger, set the trigger to repeat three times, and log information to the file file00.daq.
  4. Acquire data -- Start ai, wait for ai to stop running, and extract all the data stored in the log file as sample-time pairs.
  1. Plot the data and label the figure axes.

    Make sure ai has stopped running before cleaning up the workspace.

  1. Clean up -- When you no longer need ai, you should remove it from memory and from the MATLAB workspace.

Retrieving Data Based on Samples

You can retrieve data based on samples using the Samples property. To retrieve samples 1000 to 2000 for both sound card channels:

Plot the data and label the figure axes.

Retrieving Data Based on Channels

You can retrieve data based on channels using the Channels property. To retrieve samples 1000 to 2000 for the second sound card channel:

Plot the data and label the figure axes.

Alternatively, you can retrieve data for the second sound card channel by specifying the channel name.

Retrieving Data Based on Triggers

You can retrieve data based on triggers using the Triggers property. To retrieve all the data associated with the second and third triggers for both sound card channels:

Plot the data and label the figure axes.

Retrieving Data Based on Time

You can retrieve data based on time using the Time property. Time must be specified in seconds and Time=0 corresponds to the first logged sample. To retrieve the first 25% of the data acquired for the first trigger:

Plot the data and label the figure axes.

Retrieving Event, Object, Channel, and Hardware Information

You can retrieve event, object, channel, and hardware information by specifying the appropriate arguments to daqread. For example, to retrieve all event information, you must return all the logged data.

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

You can retrieve the entire event log as well as object and hardware information by including info as an input argument to daqread.

To return the event log information:


  Retrieving Logged Information softscope: The Data Acquisition Oscilloscope