Data Acquisition Toolbox | ![]() ![]() |
Previewing Data
Before you extract and analyze acquired data, you might want to examine (preview) the data as it is being acquired. Previewing the data allows you to determine if the hardware is performing as expected and if your acquisition process is configured correctly. Once you are convinced that your system is in order, you might still want to monitor the data even as it is being analyzed or saved to disk.
Previewing data is managed with the peekdata
function. For example, to preview the most recent 1000 samples acquired for the analog input object ai
:
After start
is issued, you can call peekdata
. peekdata
is a nonblocking function because it immediately returns control to MATLAB. Therefore, samples might be missed or repeated.
When a peekdata
call is processed, the most recent samples requested are immediately returned, but the data is not extracted from the engine. In other words, peekdata
provides a "snapshot" of the most recent requested samples. This situation is illustrated below.
If another peekdata
call is issued, then once again, only the most recent requested samples are returned. This situation is illustrated below.
Rules for Using peekdata
Using peekdata
to preview data follows these rules:
peekdata
before a trigger executes. Therefore, peekdata
is useful for previewing data before it is logged to the engine or a disk file.
peekdata
while the device object is running. However, you can call peekdata
once after the device object stops running.
For more information about peekdata
, refer to its reference pages in Function Reference.
Example: Polling the Data Block
Under certain circumstances, you might want to poll the data block. Polling the data block is useful when calling peekdata
because this function does not block execution control. For example, you can issue peekdata
calls based on the number of samples acquired by polling the SamplesAcquired
property.
You can run this example by typing daqdoc5_1
at the MATLAB command line.
AI
for a sound card. The available adaptors and hardware IDs are found with daqhwinfo
.
AI
.
P
and T
, respectively.
duration = 10; % Ten second acquisition ActualRate = get(AI,'SampleRate'); set(AI,'SamplesPerTrigger',duration*ActualRate) figure set(gcf,'doublebuffer','on') %Reduce plot flicker P = plot(zeros(1000,1)); T = title([sprintf('Peekdata calls: '), num2str(0)]); xlabel('Samples'), axis([0 1000 -1 1]), grid on
AI
and update the display for each 1000 samples acquired by polling SamplesAcquired
. The drawnow
command forces MATLAB to update the plot. Because peekdata
is used, all acquired data might not be displayed.
AI
, you should remove it from memory and from the MATLAB workspace.
As you run this example, you might not preview all 80,000 samples stored in the engine. This is because the engine might store data faster than it can be displayed, and peekdata
does not guarantee that all requested samples are processed.
![]() | Managing Acquired Data | Extracting Data from the Engine | ![]() |