Wait until analog input or output device object stops running
Note: You cannot use the legacy interface on 64–bit MATLAB®. See Session-Based Interface to acquire and generate data.
A device object or an array of device objects.
The maximum time to wait for obj to stop running.
wait(obj,waittime) blocks the MATLAB Command Window, and waits for obj to stop running. You specify the maximum waiting time, in seconds, with waittime. waittime overrides the value specified for the Timeout property. If obj is an array of device objects, then wait might wait up to the specified time for each device object in the array.
wait is particularly useful if you want to guarantee that the specified data is acquired before another task is performed.
Create the analog input object ai for a National Instruments® board, add eight channels to it, and configure a 25-second acquisition.
ai = analoginput('nidaq','Dev1'); ch = addchannel(ai,0:7); ai.SampleRate = 2000; ai.TriggerRepeat = 4; ai.SamplesPerTrigger = 10000;
You can use wait to block the MATLAB Command Window until all the requested data is acquired. Because the expected acquisition time is 25 seconds, the waittime argument is 26. If the acquisition does not complete within this time, then a timeout occurs.
If obj is not running when wait is issued, or if an error occurs while obj is running, then wait immediately relinquishes control of the Command Window.
When obj stops running, its Running property is automatically set to Off. obj can stop running under one of these conditions:
The requested number of samples is acquired (analog input) or sent out (analog output).
The stop function is issued on that object.
A run-time error occurs.
The Timeout property value is reached (waittime supersedes this value).
All callbacks, including the StopFcn, are executed before wait returns.