Main Content


(Not recommended) Block MATLAB until background operation completes

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



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


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.


collapse all

Create a session and add an analog output channel.

s = daq.createSession('ni');

Queue some output data.


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

% Perform other MATLAB operations.

Queue more data and wait for up to 15 seconds.

% Perform other MATLAB operations.

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.