You start an analog input object with the
For example, to start the analog input object
ai = analoginput('winsound') addchannel(ai,1:2) start(ai)
start is issued, the
Running property is automatically set to
and both the device object and hardware device execute according to
the configured and default property values.
While you are acquiring data with an analog input object, you
can preview the data with the
a "snapshot" of the most recent data but does not remove data from
the engine. For example, to preview the most recent 500 samples acquired
by each channel contained by
data = peekdata(ai,500);
Because previewing data is usually a low-priority task,
not guarantee that all requested data is returned. You can preview
data at any time while the device object is running. However, you
peekdata in conjunction with hardware
triggers because the device is idle until the hardware trigger is
While the analog input object is running, you can log acquired
data to the engine (memory) or to a disk file. However, before you
can log data a trigger must occur. You configure an analog input trigger
For a detailed description of triggers, see Configure Analog Input Triggers.
When the trigger occurs, the
is automatically set to
On and data acquired from
the hardware is logged to the engine or a disk file. You extract logged
data from the engine with the
For example, to extract all logged samples for each channel contained
data = getdata(ai);
getdata blocks the MATLAB® Command Window
until all the requested data is returned to the workspace. You can
extract data any time after the trigger occurs. You can also return
sample-time pairs with
getdata. For example, to
extract 500 sample-time pairs for each channel contained by
[data,time] = getdata(ai,500);
time is an m-by-1 array containing relative
time values for all m samples. Time is measured relative to the time
the first sample is logged, and is measured continuously until the
acquisition stops. You can read more detail in the
getdata reference page.
You can log data to disk with the
You can replay data saved to disk with the
Refer to Log Information to Disk for more information about
An analog input object can stop under one of these conditions:
You issue the
The requested number of samples is acquired.
A run-time hardware error occurs.
A time-out occurs.
When the device object stops, the
Logging properties are automatically set
Off. At this point, you can reconfigure the
device object or immediately issue another
using the current configuration.