getscalar4D

Purpose

Gets a scalar from a 4-dimensional array.

Format

y = getscalar4D(a, i1, i2, i3, i4)
Parameters:
  • a (4-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 second fastest moving dimension of the array.

  • i4 (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, ... ,120
a = seqa(1, 1, 120);

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

// Get the scalar in the 1,3,2,5 element
y = getscalar4D(a, 1, 3, 2, 5);

The code above assigns y equal to 50.

Remarks

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

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

See also

Functions getmatrix(), getscalar3D(), getarray()