| Data Acquisition Toolbox | Search  Help Desk |
Example: Using putdata
The example below illustrates how you can useputdata to queue 8000 samples, and then output the data a total of five times using the RepeatOutput property.
Initialization: Create the analog output object AO for a sound card. The installed adaptors and hardware ID's are found with daqhwinfo.
Configuration: Add one channel toAO = analogoutput('winsound');%AO = analogoutput('winsound');
AO, define an output time of one second, assign values to the basic setup properties, generate data to be queued, and issue two putdata calls. Since five triggers and two putdata calls are issued, a total of ten seconds of data is output.
Execution: Display summary information, startchans = addchannel(AO, 1);%chans = addchannel(AO, 0);duration = 1;set(AO, 'SampleRate', 8000);ActualRate = get(AO,'SampleRate'); len = ActualRate*duration set(AO, 'RepeatOutput', 4); data = sin(linspace(0, 2*pi, len))';putdata(AO, data);putdata(AO, data);
AO, and wait for the device object to stop running.
Termination: DeleteAOstart(AO);while strcmp(AO.Running, 'On') end
AO.
delete(AO)