Subscript ranges are used to select a subarray from an array by giving the starting and ending subscripts of the subarray in each dimension. Subscript ranges can be combined with scalar and array subscripts and with other subscript ranges. Any rectangular portion of an array can be selected with subscript ranges. There are six types of subscript ranges:
vec is a 50-element vector, vec[5:9] is a five-element vector composed of vec[5] through vec[9].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]. vec[10:*] is a 40-element vector made from vec[10] through vec[49]. vec[10:*:4] is a 10-element vector made from every fourth element between vec[10] through vec[49]. 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.
Multidimensional subarrays can be specified using any combination of the above forms. For example, arr[*, 0:4] is made from all columns of rows 0 to 4 of arr or a 10-column, 5-row array. The table below summarizes the possible forms of subscript ranges: