(Not recommended) Add analog input channel
session object function is not recommended. Use
object functions instead. See Compatibility Considerations.
adds a channel on the device represented by
deviceID, with the
channelID, and channel measurement type represented by
measurementType, to the session
Measurement types are vendor-specific.
daq.createSessionto create a session object before you use this method.
To use counter channels, see
creates and returns the channel object
ch = addAnalogInputChannel(
Add an Analog Input Current Channel
s = daq.createSession('ni') addAnalogInputChannel(s,'cDAQ1Mod3','ai0','Current');
Add an Analog Input Channel and Return Its Index
s = daq.createSession('ni') [ch,idx] = addAnalogInputChannel(s,'cDAQ2Mod6','ai0','Thermocouple')
Add a Range of Analog Input Channels
s = daq.createSession('ni') ch = addAnalogInputChannel(s,'cDAQ1Mod1',[0 2 4],'Voltage');
s — Data acquisition session
session object handle
Data acquisition session specified as a session object handle, created
daq.createSession. Use the data
acquisition session for acquisition and generation operations. Create one
session per vendor and use that vendor session to perform all data
deviceID — Device ID
character vector or string
Device ID specified as a character vector or string, as defined by the
device vendor. Obtain the device ID by calling
channelID — Channel ID
numeric value, character vector, or string
Channel ID specified as a numeric value, character vector, or string; or
the physical location of the channel on the device. Supported values are
specific to the vendor and device. You can add multiple channels by
specifying the channel ID as a numeric vector, or an array of character
vectors or strings. The index for this channel in the
session display indicates the position of this channel in the session. This
channel ID is not the same as channel index in the session: if you add a
channel with ID
2 as the first channel in a session, the
session channel index is
measurementType — Channel measurement type
character vector or string
Channel measurement type specified as a character vector or string.
measurementType represents a vendor-defined
measurement type. Valid measurement types include:
Not all devices support all types of measurement.
ch — Analog input channel object
Analog input channel that you add, returned as an object containing a 1-by-n array of vendor-specific channel information. Use this channel object to access device and channel properties.
idx — Channel index
Channel index returned as a numeric value. With this index, you can access the array of the session object Channels property.
Version HistoryIntroduced in R2010b
session object interface is not recommended
Use of this function with a
session object is not recommended. To
access a data acquisition device, use a
with its functions and properties instead.
For more information about using the recommended functionality, see Transition Your Code from Session to DataAcquisition Interface.