| Data Acquisition Toolbox | Search  Help Desk |
| peekdata | Examples See Also |
Immediately return data to the MATLAB workspace for an analog input object.
Syntax
data = peekdata(obj, samples)
Arguments
obj |
An existing analog input object. |
samples |
The number of samples to return. |
data |
An m-by-n matrix where m is the number of samples and n is the number of channels. |
Description
peekdata is a nonblocking function that allows you to preview your data by immediately returning the requested number of samples to MATLAB. Since peekdata does not block execution control, data may be missed or repeated. If the number of samples requested is greater than the number of samples available in the current block, then whatever samples are available are returned along with a warning message stating that the requested samples are not available.
peekdata takes a "snapshot" of the most recent data and does not remove samples from the data acquisition engine. Therefore, the SamplesAvailable property value is not affected by the number of samples returned by peekdata. Unlike getdata, peekdata can be used without Logging being On.
data = peekdata(obj, samples) returns the latest number of samples to data.
Note:
peekdata can be used only after the start command is issued.
Example
National Instruments
Suppose you create the analog input objectai for a National Instruments board, add eight input channels, and configure ai for a one second acquisition.
ai = analoginput('nidaq', 1)
addchannel(ai, 0:7)
set(ai, 'SampleRate', 1000);
set(ai, 'SamplesPerTrigger', 1000);
After issuing the start command, you can preview the data.
start(ai)
data = peekdata(ai, 100);
peekdata returns 100 samples to data for all eight channel group members. If 100 samples are not available, then whatever samples are available will be returned. The data is not removed from the data acquisition engine.
See Also
Functions
getdata, getsample
Properties
SamplesAvailable