indexcat#
Purpose#
Returns the indices of the elements of a vector which fall into a specified category
Format#
- y = indexcat(x, v)#
- Parameters:
x (Nx1 vector) – data
v (scalar or 2x1 vector) –
If scalar, the function returns the indices of all elements of x equal to v. If 2x1, then the function returns the indices of all elements of x that fall into the range:
\[v[1] < x <= v[2]\]If v is scalar, it can contain a single missing to specify the missing value as the category.
- Returns:
y (Lx1 vector) – Indices of the elements of x which fall into the category defined by v. It will contain error code 13 if there are no elements in this category.
Examples#
x = { 1.0, 4.0, 3.3, 4.2, 6.0, 5.7, 8.1, 5.5 };
v = { 4, 6 };
indx = indexcat(x, v);
inBds = x[indx]
4 4.20
indx = 5 inBds = 6.00
6 5.70
8 5.50
See also
Functions contains()
, ismember()
, rowcontains()