Main Content


(Not recommended) Start background operations

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



startBackground(s); starts the operation of the session object, s, without blocking the MATLAB command line and other code. To block MATLAB execution, use startForeground.

When you use startBackground(s) with analog input channels, the operation uses the DataAvailable event to deliver the acquired data. This event is fired periodically while an acquisition is in progress. For more information, see Event and Listener Concepts.

When you add analog output channels to the session, you must call queueOutputData before calling startBackground.

During a continuous generation, the DataRequired event is fired periodically to request additional data to be queued to the session.

By default, the IsContinuous property is set to false and the operation stops automatically. If you have set it to true, use stop to stop background operations explicitly.

Use wait to block MATLAB execution until a background operation is complete.


  • Create an acquisition session and add a channel before you use this method. See daq.createSession for more information.

  • If your session has analog input channels, you must use a DataAvailable event to receive the acquired data in a background acquisition.

  • If your session has analog output channels and is continuous, you can use a DataRequired event to queue additional data during background generations.

  • Call prepare to reduce the latency associated with startup and to preallocate resources.

  • Use an ErrorOccurred event to display errors during an operation.


collapse all

Create a session and add a listener. Use the listener callback function to access the acquired data.

s = daq.createSession('ni');
lh = addlistener(s,'DataAvailable',@plotData); 
function plotData(src,event)

Start the session and perform other MATLAB® operations.


Perform other MATLAB operations.

For a continuous background generation, add a listener event to queue additional data to be output.

s = daq.createSession('ni');
s.IsContinuous = true;
lh = addlistener(s,'DataRequired', ...
        @(src,event) src.queueOutputData(data));

Perform other MATLAB operations during the generation.

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.

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.