Generate Signals in the Background

This example shows how to generate signals in the background while MATLAB continues to run.

Create an NI DataAcquisition object and add an analog output voltage channel from cDAQ1Mod2:

d = daq("ni");

Specify the channel ID on NI devices using a terminal name, like 'ao1', or a numeric equivalent like 1.

Create the data to output:

outputData = (linspace(-1,1,5000)');

In this case, 5000 scans will run for 5 seconds.

Queue the output data:


Start signal output generation:


You can execute other MATLAB® commands while the generation is in progress. In this example, call pause, which causes the MATLAB command line to wait for you to press any key.


Related Topics