Main Content

addoutput

R2026b

Add output channel to device interface

Description

addoutput(d,deviceID,channelID,measurementType) adds the output channel channelID of device deviceID to the specified DataAcquisition interface, d, configured for the specified measurement type. Access the channel information from the Channels property of d.

ch = addoutput(___) adds the channel and returns a channel object.

[ch,idx] = addoutput(___) adds the channel and also returns the channel index from the DataAcquisition interface. The channel index indicates the sequence in which you add channels to the DataAcquisition interface; do not confuse it with the device channel ID.

example

Examples

collapse all

Add multiple channels to a DataAcquisition interface, and use indices to view their settings.

d = daq('directsound');
ch1 = addoutput(d,"Audio3","1","Audio");
[ch2,idx2] = addoutput(d,"Audio6","1","Audio");
d.Channels
    Index     Type      Device     Channel    Measurement Type        Range            Name   
    _____    ______    ________    _______    ________________    ______________    __________

      1      "audo"    "Audio3"      "1"          "Audio"         "-1.0 to +1.0"    "Audio3_1"
      2      "audo"    "Audio6"      "1"          "Audio"         "-1.0 to +1.0"    "Audio6_1"

Access one of the channel settings using its index.

d.Channels(idx2).Type
    'AudioOutputChannel'

Input Arguments

collapse all

DataAcquisition interface, specified as a DataAcquisition object, created using the daq function.

Example: d = daq()

Device ID specified as a character vector or string, as defined by the device vendor. Obtain the device ID by calling daqlist.

Example: "Dev1"

Data Types: char | string

Channel ID, specified as a numeric value, character vector, or string; typically indicates the physical location of the channel on the device. Supported values depend on the vendor and device. To add multiple channels, specify the channel ID as a numeric vector or a cell array of character vectors or strings.

The channel ID is not the same as the channel index. The index is the position of the channel in the DataAcquisition interface display. For example, if you add a channel with ID 2 as the first channel in a DataAcquisition interface, the index for this channel is 1.

Tip: For best performance when adding multiple channels, specify the channels as a vector in one call to addoutput, rather than calling addoutput for each channel.

Example: "ao2"

Data Types: char | string | numeric | cell

Channel measurement type, specified as a string or character vector. measurementType represents a vendor-defined measurement type. Valid measurement types include the following:

Measurement TypeSubsystem
'Voltage'

Analog Output

'Current'

Analog Output

'Digital'

Digital I/O

'PulseGeneration'

Counter Output

'Audio'

Audio Output

'Sine'

Function Generator

'Square'

Function Generator

'Triangle'

Function Generator

'RampUp'

Function Generator

'RampDown'

Function Generator

'DC'

Function Generator

'Arbitrary'

Function Generator

Not all devices support all measurement types.

Example: "Voltage"

Data Types: char | string

Output Arguments

collapse all

Channel, returned as a channel object with properties depending on the measurement type as described in Channel Properties.

Channel index, returned as a numeric value. With this index, you can access the array of the DataAcquisition Channels property.

Version History

Introduced in R2020a