| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Data Acquisition Toolbox |
| Contents | Index |
| Learn more about Data Acquisition Toolbox |
| On this page… |
|---|
At the core of any analog output application lies the data you want to send from a computer to an output device such as an actuator. The role of the analog output subsystem is to convert digitized data to analog data for subsequent output.
Before you can output data to the analog output subsystem, it must be queued in the engine. Queuing data is managed with the putdata function. In addition to this function, there are several properties associated with managing output data. These properties are given below.
Table 6-6. Analog Output Data Management Properties
Property Name | Description |
|---|---|
Indicate the maximum number of samples that can be queued in the engine. | |
Specify the number of additional times queued data is output. | |
Specify an additional waiting time to queue data. |
Before data can be sent to the analog output hardware, you must queue it in the engine. Queuing data is managed with the putdata function. One column of data is required for each channel contained by the analog output object. For example, to queue one second of data for each channel contained by the analog output object ao:
ao = analogoutput('winsound');
addchannel(ao,1:2);
data = sin(linspace(0,2*pi*500,8000))';
putdata(ao,[data data])
A data source consisting of m samples and n channels is illustrated below.

Using putdata to queue data in the engine follows these rules:
You must queue data in the engine before starting the analog output object.
If the value of the RepeatOutput property is greater than 0, then all queued data is automatically requeued until the RepeatOutput value is reached. You must configure RepeatOutput before start is issued.
While the analog output object is running, you can continue to queue data unless RepeatOutput is greater than 0.
You can queue data in the engine until the value specified by the MaxSamplesQueued property is reached, or the limitations of your hardware or computer are reached.
Data to be queued in the engine follows these rules:
Data is output as soon as a trigger occurs.
An error is returned if a NaN is included in the data stream.
You can use the native data type of the hardware.
If the data is not within the range of the UnitsRange property, then it is clipped to the maximum or minimum value specified by UnitsRange. Refer to Linearly Scaling the Data for more information about clipping.
This example illustrates how you can use putdata to queue 8000 samples, and then output the data a total of five times using the RepeatOutput property.
To run this example type daqdoc6_3 at the MATLAB Command Window.
Create a device object — Create the analog output object AO for a sound card. The installed adaptors and hardware IDs are found with daqhwinfo.
AO = analogoutput('winsound');
%AO = analogoutput('nidaq','Dev1');
%AO = analogoutput('mcc',1);Add channels — Add one channel to AO.
chans = addchannel(AO,1); %chans = addchannel(AO,0); % For NI and MCC
Configure property values — Define an output time of one second, assign values to the basic setup properties, generate data to be queued, and issue two putdata calls. Because the queued data is repeated four times and two putdata calls are issued, a total of 10 seconds of data is output.
duration = 1; set(AO,'SampleRate',8000) ActualRate = get(AO,'SampleRate'); len = ActualRate*duration; set(AO,'RepeatOutput',4) data = sin(linspace(0,2*pi*500,len))'; putdata(AO,data) putdata(AO,data)
Output data — Start AO and wait for the device object to stop running.
start(AO) wait(AO,11)
Clean up — When you no longer need AO, you should remove it from memory and from the MATLAB workspace.
delete(AO) clear AO
![]() | Getting Started with Analog Output | Configuring Analog Output Triggers | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |