getscalar3D#

Purpose#

Gets a scalar from a 3-dimensional array.

Format#

y = getscalar3D(a, i1, i2, i3)#
Parameters:
  • a (3-dimensional array) – Data

  • i1 (scalar) – index into the slowest moving dimension of the array.

  • i2 (scalar) – index into the second slowest moving dimension of the array.

  • i3 (scalar) – index into the fastest moving dimension of the array.

Returns:

y (scalar) – the element of the array indicated by the indices.

Examples#

// Create a column vector 1, 2, 3,...24
a = seqa(1, 1, 24);

// Reshape the column vector into a 2x3x4 dimensional array
a = areshape(a, 2|3|4);

y = getscalar3D(a, 1, 3, 2);

A 2x3x4 dimensional array can be thought of as two 3x4 dimensional matrices. The call to getScalar3D() above, returns the \([3,2]\) element of the first of these matrices. The value of which is:

y = 10

Remarks#

getscalar3D() returns the scalar that is located in the \([i1, i2, i3]\) position of array a.

A call to getscalar3D() is faster than using the more general getmatrix() function to get a scalar from a 3-dimensional array.

See also

Functions getmatrix(), getscalar4D(), getarray()