>  Docs Center  >  Using ENVI  >  Extract Elements From Arrays

Extract Elements From Arrays

Extract Elements From Arrays

Add an Extract Elements from Arrays node to extract one or more elements from a 1-D or multi-dimensional array. Follow these steps:

  1. Double-click Extract Elements from Arrays in the Tasks list.
  2. Draw a connector between an array input node, and the Extract Elements from arrays node. Examples of array input include an Array of Values node or a task that produces an array.
  3. Click the button in the Extract Elements from Array node. The Extract Elements from Array dialog appears, listing the known properties and metadata items from the input.
  4. In the Indices field, specify one or more zero-based elements to extract from the input array. For 1-D arrays, this is the subscript of the array element. For example, if the array is [1, 2, 3, 4, 5, 6] and you want to extract the third element (with a value of 3), enter an Indices value of 2. See the table below for guidelines on specifying ranges of subscripts.
  5. For multi-dimensional arrays, specify the 1-D subscript of the array element to extract. For example, suppose that you have an array with three columns and two rows:

    1 2 3
    4 5 6

    To extract the array element in the first column and second row (with a value of 4), enter an Indices value of 3. Array elements are stored in row order in IDL.

  6. Click OK.

Array Subscript Ranges

The following table summarizes the different ways to specify ranges of array subscripts.

Subscript Format



A simple subscript, either positive or negative.

Positive subscripts are indexed from the beginning of the array, while negative subscripts are indexed from the end (where -1 is the last element). When used with multidimensional arrays, simple subscripts specify only elements with subscripts equal to the given subscript in that dimension.


Subscript range from s0 to s1.

This denotes all elements whose subscripts range from the expression s0 through s1(s0 must not be greater than s1). For example, if the variable vec is a 10-element vector, vec[4:8] is a five-element vector composed of vec[4] through vec[8]. Negative indices may be used, where -1 indicates the last element. For example, vec[-6:-2] returns the same five elements as vec[4:8].


Every n-th element in a range of subscripts from s0 to s1.

The expression n is referred to as the subscript stride. The stride value may be positive or negative (but must not be zero). If the stride is positive then s0 must be less than or equal to s1. If the stride is negative then s0 must be greater than or equal to s1. If the stride is 1, then the result is identical in meaning to [s0:s1], as described above. For example, if the variable vec is a 50-element vector, vec[5:13:2] is a five-element vector composed of vec[5], vec[7], vec[9], vec[11], and vec[13]. In another example, vec[-1:0:-3] would return every third element of vec, in reverse order.

See Also

Add Tasks to Models, Specify Input Datasets and Task Parameters

© 2020 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us