Main Content

wait

(Not recommended) Block MATLAB until background operation completes

This session object function is not recommended. Use DataAcquisition object functions instead. See Compatibility Considerations.

Description

example

wait(s) blocks MATLAB® until the background operation completes. To abort the wait, press Ctrl+C.

Tips

You cannot call wait if you have set the session IsContinuous property to true. To terminate the operation in this case, use the stop function.

wait(s,timeout) blocks MATLAB until the operation completes or the specified timeout occurs. If the session operation does not complete before this timeout occurs, MATLAB is unblocked, an error is thrown, and the data acquisition session operation continues running.

Examples

collapse all

Create a session and add an analog output channel.

s = daq.createSession('ni');
addAnalogOutputChannel(s,'cDAQ1Mod2','ao0','Voltage');

Queue some output data.

queueOutputData(s,zeros(10000,1));

Start the session, then issue a wait. This blocks MATLAB until all data is output.

startBackground(s);
% Perform other MATLAB operations.
wait(s)

Queue more data and wait for up to 15 seconds.

queueOutputData(s,zeros(10000,1));
startBackground(s);
% Perform other MATLAB operations.
wait(s,15)

Input Arguments

collapse all

Data acquisition session, specified as a session object. Create the session object using daq.createSession. Use the data acquisition session for acquisition and generation operations. Create one session per vendor and use that vendor session to perform all data acquisition operations.

Session timeout value in seconds, specified as a numeric value. This value is the maximum time in seconds to wait.

Version History

Introduced in R2010b

collapse all

R2020a: session object interface is not recommended

Use of this function with a session object is not recommended. To access a data acquisition device, use a DataAcquisition object with its functions and properties instead.

For more information about using the recommended functionality, see Transition Your Code from Session to DataAcquisition Interface.