XTOIDX

Purpose:

Converts X values of a series to index values.

Syntax:

XTOIDX(series, x, limit)

series

-

An input series

x

-

A real or a series of reals. The X values to convert to indices.

limit

-

Optional. An integer, limit result to the existing indices range.

0:

do not limit output

1:

limit output to existing indices range (default)

Returns:

A real or series.

Example:

W1: 1..0.1..10

W2: xtoidx(W1, 1..0.1..1.5)

 

W2 contains the series {1, 2, 3, 4, 5, 6}, the first 6 index values of W1.

Example:

W1: 1..0.1..10

W2: xtoidx(W1, 8..20)

W3: xtoidx(W1, 8..20, 0)

 

The values in W2 range from 71 to 91. Because some x values correspond to a indices larger than the length of W1, the result is limited to the length of W1. The resulting indices in W3 are not limited to the indices of W1 and range from 71 to 191.

Remarks:

Indices start at 1 unless STARTINDEX is invoked or the SPL_START_INDEX configuration parameter is set.

 

For XY or XYZ series, the indices are looked up and the closest matches are returned.

 

For interval series, the indices are computed as follows:

 

idx = start + int((x - xoffset(s)) / deltax(s) + 0.5); 

 

where start is the value of STARTINDEX or SPL_START_INDEX (usually 1).

 

If limit is set to 0, XTOIDX can return index value outside the range of the input series.

See Also:

IDX

IDXTOX

STARTINDEX

XVALS