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"); addoutput(d,"cDAQ1Mod2","ao0","Voltage");
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:
preload(d,outputData);
Start signal output generation:
start(d);
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.
pause