Data Acquisition Toolbox | ![]() ![]() |
Mapping Hardware Channel IDs to MATLAB Indices
When you add channels to a device object, the resulting channel group consists of a mapping between hardware channel IDs and MATLAB indices.
Hardware channel IDs are numeric values defined by the hardware vendor that uniquely identify a channel. For National Instruments and Measurement Computing hardware, the channel IDs are "zero-based" (begin at zero). For Agilent Technologies hardware and sound cards, the channel IDs are "one-based" (begin at one). However, when you reference channels, you use the MATLAB indices and not the hardware IDs. Given this, you should keep in mind that MATLAB is one-based. You can return the vendor's hardware IDs with the daqhwinfo
function.
For example, suppose you create the analog input object ai
for a National Instruments board and you want to add the first three differential channels.
To return the hardware IDs, supply the device object to daqhwinfo
, and examine the DifferentialIDs
field.
The first three differential channels have IDs 0
, 1
, and 2
, respectively.
The index assigned to a hardware channel depends on the order in which you add it to the device object. In the above example, the channels are automatically assigned the MATLAB indices 1, 2, and 3, respectively. You can change the hardware channels associated with the MATLAB indices using the HwChannel
property. For example, to swap the order of the second and third hardware channels,
The original and modified index assignments are shown below.
Note If you are using scanning hardware, then the MATLAB indices define the scan order; index 1 is sampled first, index 2 is sampled second, and so on. |
For digital I/O objects, the diagram would look the same except that lines would be substituted for channels.
![]() | Adding Channels or Lines | Configuring and Returning Properties | ![]() |