Main Content

removechannel

Remove channel from device interface

Since R2020a

Description

removechannel(d,idx) removes the specified channels from the DataAcquisition interface. If the DataAcquisition has channels with indices higher than the channels being removed, they are renumbered to fill the empty gaps left by the removal, but the channel names do not change.

example

Examples

collapse all

Remove channels from a DataAcquisition and note the index changes.

d = daq("directsound");
addinput(d,"Audio0","1","Audio");
addinput(d,"Audio1","1","Audio");
addoutput(d,"Audio3","1","Audio");
addoutput(d,"Audio6","1","Audio");
d.Channels
index     Type      Device     Channel    Measurement Type         Range         Name 
_____    ______    ________    _______    ________________    _______________    _____

  1      "audi"    "Audio1"      "1"          "Audio"         "-1.0 to +1.0 "    "ch1"
  2      "audi"    "Audio0"      "1"          "Audio"         "-1.0 to +1.0 "    "ch2"
  3      "audo"    "Audio3"      "1"          "Audio"         "-1.0 to +1.0 "    "ch3"
  4      "audo"    "Audio6"      "1"          "Audio"         "-1.0 to +1.0 "    "ch4"
removechannel(d,2)
d.Channels
index     Type      Device     Channel    Measurement Type         Range         Name 
_____    ______    ________    _______    ________________    _______________    _____

  1      "audi"    "Audio1"      "1"          "Audio"         "-1.0 to +1.0 "    "ch1"
  2      "audo"    "Audio3"      "1"          "Audio"         "-1.0 to +1.0 "    "ch3"
  3      "audo"    "Audio6"      "1"          "Audio"         "-1.0 to +1.0 "    "ch4"

Note that after removal of the second channel, the remaining channels are numbered 1, 2, and 3. The channel names are not changed.

Remove all remaining channels.

removechannel(d,[1:length(d.Channels)])

Input Arguments

collapse all

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

Example: d = daq()

Channel index, specified as a numeric scalar or vector. Removing a channel shifts down the indices of remaining higher channels, but does not change the channel names. Do not confuse the channel index in the DataAcquisition with the channel ID of the data acquisition device.

Example: [1,3]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Version History

Introduced in R2020a

See Also

Functions