getarray#

Purpose#

Gets a contiguous subarray from an N-dimensional array.

Format#

y = getarray(a, loc)#
Parameters:
  • a (N-dimensional array) – array

  • loc (Mx1 vector) – vector of indices into the array to locate the subarray of interest where \(1 <= M <= N\).

Returns:

y ([N-M]-dimensional array or scalar) – The subarray of interest located in the loc of a.

Examples#

// Generate vector
vec_st = seqa(1, 1, 720);

// Reshape `vec` into array
a = areshape(vec_st, 2|3|4|5|6);

// Location index
loc = { 2, 1 };

// Get scalar at location 2,1 of array a
y = getarray(a, loc);

y will be a 4x5x6 array of sequential values, beginning at \([1,1,1]\) with 361, and ending at \([4,5,6]\) with 480.

Remarks#

If \(N - M > 0\), getarray() will return an array of [N-M] dimensions, otherwise, if \(N - M = 0\), it will return a scalar.

See also

Functions getmatrix()