IDL array subscript

There are six types of subscript ranges:

Subscript Format

Description

[*]

All elements of a dimension.

This form is used with multidimensional arrays to select all elements along the dimension. For example, if arr is a 10-column by 12-row array, arr[*, 11] is the last row of arr, composed of elements [arr[0,11], arr[1,11], ..., arr[9,11]], and is a 10-element row vector. Similarly,arr[0, *] is the first column of arr[arr[0,0], arr[0,1],..., arr[0,11]], and its dimensions are 1 column by 12 rows.

[s0:s1]

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].

[s0:*]

or

[s0:-1]

A range from the given element to the last element of dimension.

This denotes all elements from a given element to the last element of the dimension. If the variablevec is a 50-element vector, vec[10:*] is a 40-element vector made from vec[10] through vec[49].

[s0:s1:n]

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.

[s0:*:n]

or

[s0:-1:n]

Every n-th element from element s0 to the end of the dimension.

The expression n is referred to as the subscript stride. If the variable vec is a 50-element vector,vec[10:*:4] is a 10-element vector made from every fourth element between vec[10] throughvec[46].

[n]

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.

Multidimensional subarrays can be specified using any combination of the above forms. For example, if arr is a 10x10 array, arr[*,0:4] returns a 10 x 5 array that is made from all columns of rows 0 to 4 of arr.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值