This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

DataRequired Event

Notify when additional data is required for output on continuous generation


lh = addlistener(session,'DataRequired',callback);
lh = addlistener(session,'DataRequired',@(src,event) expr);


lh = addlistener(session,'DataRequired',callback); creates a listener for the DataRequired event. When more data is required, the callback is executed. The callback can be any MATLAB® function with the (src,event) signature.

lh = addlistener(session,'DataRequired',@(src,event) expr); creates a listener for the DataRequired event and fires an anonymous function. The anonymous function requires the specified input arguments and executes the operation specified in the expression expr. Anonymous functions provide a quick means of creating simple functions without storing your function to a file. For more information see Anonymous Functions.

The callback has two required parameters: src and event. src is the session object for the listener and event is a daq.DataRequiredInfo object.


    • The callback is typically used to queue more data to the device.

    • Frequency is controlled by NotifyWhenScansQueuedBelow.


collapse all

Create a session and add two analog output channels.

s = daq.createSession('ni');
s.IsContinuous = true

Create output data for the two channels.

outputData0 = (linspace(-1,1,1000))';
outputData1 = (linspace(-2,2,1000))';

Queue the output data, add an anonymous listener, and generate the signal in the background.

lh = addlistener(s,'DataRequired', ...
			@(src,event) src.queueOutputData([outputData0,outputData1]));

Generate the output data and pause for up to 15 seconds.


Delete the listener.

Was this topic helpful?