Data Acquisition Toolbox    

Referencing Individual Hardware Channels

As described in the preceding section, you can access channels with the Channel property or with a channel object. To reference individual channels, you must specify either MATLAB indices or descriptive channel names.

MATLAB Indices

Every hardware channel contained by an analog input object has an associated MATLAB index that is used to reference the channel. When adding channels with the addchannel function, index assignments can be made automatically or manually. In either case, the channel indices start at 1 and increase monotonically up to the number of channel group members.

For example, the analog input object ai created in the preceding section had the MATLAB indices 1 and 2 automatically assigned to the hardware channels 0 and 1, respectively. To manually swap the hardware channel order, you supply the appropriate index to chans and use the HwChannel property.

Alternatively, you can use the Channel property.

Note that you can also use addchannel to specify the required channel order.

Descriptive Channel Names

Choosing a unique, descriptive name can be a useful way to identify and reference channels -- particularly for large channel groups. You can associate descriptive names with hardware channels using the addchannel function. For example, suppose you want to add 16 single-ended channels to ai, and you want to associate the name TrigChan with the first channel in the group.

Alternatively, you can use the ChannelName property.

You can now use the channel name to reference the channel.


  Adding Channels to an Analog Input Object Example: Adding Channels for a Sound Card