Main Content

removeChannel

(Not recommended) Remove channel from session object

This session object function is not recommended. Use DataAcquisition object functions instead. See Compatibility Considerations.

Description

example

removeChannel(s,idx); removes the channel specified by idx from the session object s.

Examples

collapse all

Start with a session s, to which you add two analog input and two analog output voltage channels and display the channel information.

s
s = 

Data acquisition session using National Instruments hardware:
   No data queued.  Will run at 1000 scans/second.
   Operation starts immediately.
      Number of channels: 4
      index Type  Device   Channel   MeasurementType      Range           Name
      ----- ---- --------- ------- -------------------   ---------------- ----
      1     ai   cDAQ1Mod4 ai0     Voltage (SingleEnd)   -10 to +10 Volts
      2     ai   cDAQ1Mod4 ai1     Voltage (SingleEnd)   -10 to +10 Volts
      3     ao   cDAQ1Mod2 ao0     Voltage (Diff)        -10 to +10 Volts
      4     ao   cDAQ1Mod2 ao1     Voltage (Diff)        -10 to +10 Volts

Remove channel 'ai0' with the index 1 from the session:

removeChannel(s,1)

To see how the indices shift after you remove a channel, type:

s
s = 

Data acquisition session using National Instruments hardware:
   No data queued.  Will run at 1000 scans/second.
   All devices synchronized using cDAQ1 CompactDAQ chassis backplane. (Details)
      Number of channels: 3
      index Type  Device   Channel   MeasurementType     Range            Name
      ----- ---- --------- ------- -------------------   ---------------- ----
      1     ai   cDAQ1Mod4 ai1     Voltage (SingleEnd)   -10 to +10 Volts
      2     ao   cDAQ1Mod2 ao0     Voltage (Diff)        -10 to +10 Volts
      3     ao   cDAQ1Mod2 ao1     Voltage (Diff)        -10 to +10 Volts

Remove the first output channel 'ao0' at index 2:

removeChannel(s,2);

The session now displays one input and one output channel:

s.Channels
ans = 

Number of channels: 2
      index Type  Device   Channel   MeasurementType     Range            Name
      ----- ---- --------- ------- -------------------   ---------------- ----
      1     ai   cDAQ1Mod4 ai1     Voltage (SingleEnd)   -10 to +10 Volts
      2     ao   cDAQ1Mod2 ao1     Voltage (Diff)        -10 to +10 Volts

Input Arguments

collapse all

Data acquisition session, specified as a session object. Create the session object using 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 acquisition operations.

Channel index, specified as a numeric value. Use the index of the channel that you want to remove from the session.

Version History

Introduced in R2010b

collapse all

R2020a: 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 DataAcquisition object with its functions and properties instead.

For more information about using the recommended functionality, see Transition Your Code from Session to DataAcquisition Interface.