dash.assert.indices

Throw error if input is neither logical indices nor linear indices


Syntax



Description

indices = dash.assert.indices(indices)

Checks if input is a vector of logical or linear indices. If not throws an error message. If so, returns the input as linear indices.

indices = dash.assert.indices(indices, length)

Also requires indices to be compatible with a specified dimension length. To be valid, a vector logical indices must match the length of the array. For linear indices, the values of individual elements cannot exceed the length of the dimension.


Customize the error message and error ID.


Input Arguments

indices

any data type
The input being tested.

length

scalar positive integer | []
The length of the array dimension that the indices are for. Logical indices must be a vector of this length, and linear indices cannot exceed this length. If an empty array, does not check indices against a dimension length

name

string scalar
A name to use for the input in error messages Default is “input”.

logicalRequirement

string scalar
A name to use for the length requirement of logical index vectors in error messages. Default is “be the length of the dimension”.

linearMaxName

string scalar
A name to use for the maximum allowed linear index. Default is “the length of the dimension”.

Output Arguments

indices

vector, linear indices
The input as linear indices.