Index Operator (FPScript)
Extracts an individual value or a section from an expression.
Syntax
TermIndex1[Index2]
where Index1 stands for the following variants:
[]
or
[Index]
or
[from, to]
or
[[ ]]
or
[[ValueIndex]]
or
[[ValueFrom, ValueTo]]
and the optional Index2 stands for the following variants:
[Index]
or
[from, to]
or
[[ValueIndex]]
or
[[ValueFrom, ValueTo]]
The syntax of the index operator consists of the following elements:
Element |
Description |
---|---|
Term |
An expression, which describes a variable, formula or data set, calls a function or selects an element from a list, or any expression in brackets. |
Index |
Specifies the number(s) of the value(s) to be indexed. Can be an integral scalar value, a data series or a data matrix with integral values or of the Empty data type. |
From |
Specifies the index of the first value of a range to be indexed. Must be a real integral scalar value or of the Empty data type. |
to |
Specifies the index of the last value of a range to be indexed. Must be a real integral scalar value or of the Empty data type. |
ValueIndex |
Specifies the X or Z values of the value(s) or signals to be indexed. Can be a numeric scalar value, a data series with numeric values or of the Empty data type. |
ValueFrom |
Specifies the X or Z value of the first value or signal of a range to be indexed. Must be a numeric scalar value or of the Empty data type. |
ValueTo |
Specifies the X or Z value of the last value or signal of a range to be indexed. Must be a numeric scalar value or of the Empty data type. |
Remarks
When written with single brackets, the Index Operator can extract individual values or sections from data series, data matrices, signals, signal series and space curves.
The indices are counted starting from zero. Negative indices are counted from the end, i.e. the index -1 corresponds to the last element, -2 corresponds to the second to last element, and so forth. For two-dimensional data structures - data matrix and signal series - two indices can be specified consecutively. The first index called Column Index applies to the data series in a data matrix or to the signals in a signal series. The optional second index is called Row index and applies to the values in the data series or signals extracted using the first index. If you leave the first index blank or specify Index as a value of the Empty data type, this indexes all data series or signals.
As the syntax shows, you can specify the index in three variations: If you specify as Index a scalar value (scalar value index), the index extracts one element, and the rank of the result decreases by one. If you specify as Index a data series (data series index) or a range from, to (range index), the values listed in the data series or the values in the range are taken. If a floating point value is specified for one of the arguments Index, from or to its fractional digits will be ignored. A void floating point value is interpreted as 0. If you set from or to as a value with the Empty data type, this corresponds to the first or last element in the data set dimension to be indexed.
To extract any scatter data from a data matrix or signal series, specify Index as a data matrix with two rows and n columns (2D Index). Each column of Index contains the column and row index of a value to be extracted. The result is then a data series or space curve with the extracted values.
If Term is a quantity, then its unit is taken and the result is also a quantity. If Index, from or to is a quantity, then it has to have the SI dimension 1 and it will be transformed to the unit 1 before indexing.
When written with double brackets, the Value Index Operator can extract individual values or sections from data series and signal series. The indexing does not happen via indices, but instead via X or Z values. Signal series with a two-dimensional X component are not supported. If the specified X or Z values do not occur exactly in the signal or in the signal series, the positions of the values closest to the specified values are used. To determine the indices corresponding to the specified X or Z values, the value index operator uses the SearchValue function. Void floating point values are not allowed as value indices.
If ValueIndex, ValueFrom or ValueTo is a quantity, then this quantity must have the same SI dimension as the corresponding component of Term and will be transformed to its unit before indexing. If only numerical values are specified without a unit, then these are interpreted as being present in the corresponding unit.
When the indexed Term represents a compound data structure, then the data structure of expression must match either the Y-component or the complete data structure. In the first case, only the indexed Y values in Term will be overwritten and in the second case, the X values and, if applicable, the Z values will be as well.
If Term is a list, then the index operation is carried out by element and the result is also a list. If Index1 and/or Index2 is a list, and if Term is also a list, then the list elements are assigned in pairs. Otherwise, only the first list element is used.
Notes:
•The index operator cannot be used to extract elements from lists. For this purpose, use the List Element Operator.
•When accessing two-dimensional data sets, you can combine the value index operator and the index operator (hybrid index).
The following table lists all of the possible index operator combinations except for the hybrid cases:
DataSeries[ScalarValue] |
Takes the value with the number specified in ScalarValue from the data series. The result is a scalar value. |
DataSeries[from, to] |
Takes the values lying in the range from, to from the data series. The result is a data series. |
DataSeries[Series] |
Takes the values specified in Series from the data series. The result is a data series. |
DataMatrix[ScalarValue] |
Takes the column with the number specified in ScalarValue from the data matrix. The result is a data series. |
DataMatrix[from, to] |
Takes the columns lying in the range from, to from the data matrix. The result is a data matrix. |
DataMatrix[Series] |
Takes the columns specified in Series from the data matrix. The result is a data matrix. |
DataMatrix[ ][ScalarValue] |
Takes the row with the number specified in ScalarValue from the data matrix. The result is a data series. |
DataMatrix[ ][from, to] |
Takes the rows lying in the range from, to from the data matrix. The result is a data matrix. |
DataMatrix[ ][Series] |
Takes the rows specified in Series from the data matrix. The result is a data matrix. |
DataMatrix[ScalarValue1][ScalarValue2] |
Takes a value from the column specified with ScalarValue1 and the row specified with ScalarValue2 from the data matrix. The result is a scalar value. |
DataMatrix[ScalarValue][from, to] |
Takes the values lying in the range from, to from the column specified in ScalarValue from the data matrix. The result is a data series. |
DataMatrix[ScalarValue][Series] |
Takes the values specified in Series from the column specified in ScalarValue from the data matrix. The result is a data series. |
DataMatrix[from, to][ScalarValue] |
Takes the value specified in ScalarValue from the columns in the range from, to from the data matrix. The result is a data series. |
DataMatrix[from1, to1][from2, to2] |
Takes the rows lying in the range from2, to2 from the columns lying in the range from1, to1 from the data matrix. The result is a data matrix. |
DataMatrix[from, to][Series] |
Takes the rows specified in Series from the columns lying in the range from, to from the data matrix. The result is a data matrix. |
DataMatrix[Series][ScalarValue] |
Takes the value specified in ScalarValue from the columns listed in Series from the data matrix. The result is a data series. |
DataMatrix[Series][from, to] |
Takes the rows lying in the range from, to from the columns listed in Series from the data matrix. The result is a data matrix. |
DataMatrix[Series1][Series2] |
Takes the rows listed in Series2 from the columns listed in Series1 from the data matrix. The result is a data matrix. |
DataMatrix[Matrix] |
Takes the values with the column and row indices listed in Matrix from the data matrix. The result is a data series. |
Signal[ScalarValue] |
Takes the Y value with the number specified in ScalarValue from the signal. The result is a scalar value. |
Signal[from, to] |
Takes the points lying in the range from, to from the signal. The result is a signal. |
Signal[Series] |
Takes the points specified in Series from the signal. The result is a signal. |
SignalSeries[ScalarValue] |
Takes the signal with the number specified in ScalarValue from the signal series. The result is a signal. |
SignalSeries[from, to] |
Takes the signals lying in the range from, to from the signal series. The result is a signal series. |
SignalSeries[Series] |
Takes the signals specified in Series from the signal series. The result is a signal series. |
SignalSeries[ ][ScalarValue] |
Takes all values with the number specified in ScalarValue from the signal series. If the signal series has a Z component, then the result is a signal or otherwise a data series. |
SignalSeries[ ][from, to] |
Takes the values lying in the range from, to from the signal series. The result is a signal series. |
SignalSeries[ ][Series] |
Takes the values specified in Series from the signal series. The result is a signal series. |
SignalSeries[ScalarValue1][ScalarValue2] |
Takes the Y value with the number specified in ScalarValue2 from the signal specified in ScalarValue1 from the signal series. The result is a scalar value. |
SignalSeries[ScalarValue][from, to] |
Takes the values lying in the range from, to from the signal specified in ScalarValue from the signal series. The result is a signal. |
SignalSeries[ScalarValue][Series] |
Takes the values specified in Series from the signal specified in ScalarValue from the signal series. The result is a signal. |
SignalSeries[from, to][ScalarValue] |
Takes the Y values with the number specified in Scalar Value from the signals lying in the range from, to from the signal series. If the signal series has a Z component, then the result is a signal or otherwise a data series. |
SignalSeries[from1, to1][from2, to2] |
Takes the points lying in the range from2, to2 from the signals lying in the range from1, to1 from the signal series. The result is a signal series. |
SignalSeries[from, to][Series] |
Takes the points specified in Series from the signals lying in the range from, to from the signal series. The result is a signal series. |
SignalSeries[Series][ScalarValue] |
Takes the Y values with the number specified in Scalar Value from the signals listed in Series from the signal series. If the signal series has a Z component, then the result is a signal or otherwise a data series. |
SignalSeries[Series][from, to] |
Takes the points lying in the range from, to from the signals listed in Series from the signal series. The result is a signal series. |
SignalSeries[Series1][Series2] |
Takes the points listed in Series2 from the signals listed in Series1 from the signal series. The result is a signal series. |
SignalSeries[Matrix] |
Takes the points with the column and row indices listed in Matrix from the signal series. The result is a space curve. |
SpaceCurve[ScalarValue] |
Takes the Y value with the number specified in ScalarValue from the space curve. |
SpaceCurve[from, to] |
Takes the points lying in the range from, to from the space curve. The result is a space curve. |
SpaceCurve[Series] |
Takes the points specified in Series from the space curve. The result is a space curve. |
The following table lists all of the possible value index operator combinations except for the hybrid cases:
Signal[[ScalarValue]] |
Takes the Y value with the X value specified in ScalarValue from the signal. The result is a scalar value. |
Signal[[from, to]] |
Takes the points lying in the X range from, to from the signal. The result is a signal. |
Signal[[Series]] |
Takes the points with the X values specified in Series from the signal. The result is a signal. |
SignalSeries[[ScalarValue]] |
Takes the signal with the Z value specified in ScalarValue from the signal series. The result is a signal. |
SignalSeries[[from, to]] |
Takes the signals lying in the Z range from, to from the signal series. The result is a signal series. |
SignalSeries[[Series]] |
Takes the signals with the Z values specified in Series from the signal series. The result is a signal series. |
SignalSeries[[ ]][[ScalarValue]] |
Takes all Y values with X value ScalarValue from the signal series. If the signal series has a Z component, then the result is a signal or otherwise a data series. |
SignalSeries[[ ]][[from, to]] |
Takes the values lying in the X range from, to from the signal series. The result is a signal series. |
SignalSeries[[ ]][[Series]] |
Takes the values with the X values specified in Series from the signal series. The result is a signal series. |
SignalSeries[[ScalarValue1]][[ScalarValue2]] |
Takes the Y value with the X value specified in ScalarValue2 from the signal with the Z values in ScalarValue1 from the signal series. The result is a scalar value. |
SignalSeries[[ScalarValue]][[from, to]] |
Takes the values lying in the X range from, to from the signal with Z value in ScalarValue from the signal series. The result is a signal. |
SignalSeries[[ScalarValue]][[Series]] |
Takes the points with the X values specified in Series from the signal with the Z value specified in ScalarValue from the signal series. The result is a signal. |
SignalSeries[[from, to]][[ScalarValue]] |
Takes the Y values with the X value ScalarValue from the signals lying in the Z range from, to from the signal series. If the signal series has a Z component, then the result is a signal or otherwise a data series. |
SignalSeries[[from1, to1]][[from2, to2]] |
Takes the values lying in the X range from2, to2 from the signals lying in the Z range from1, to1 from the signal series. The result is a signal series. |
SignalSeries[[from, to]][[Series]] |
Takes the points with the X values listed in Series from the signals lying in the Z range from, to from the signal series. The result is a signal series. |
SignalSeries[[Series]][[ScalarValue]] |
Takes the Y values with the X value ScalarValue from the signals with the Z values listed in Series from the signal series. If the signal series has a Z component, then the result is a signal or otherwise a data series. |
SignalSeries[[Series]][[from, to]] |
Takes the points lying in the X range from, to from the signals with the Z values specified in Series from the signal series. The result is a signal series. |
SignalSeries[[Series1]][[Series2]] |
Takes the points with the X values listed in Series2 from the signals with the Z values listed in Series1 from the signal series. The result is a signal series. |
SpaceCurve[[ScalarValue]] |
Takes the Y value with the X value specified in ScalarValue from the space curve. The result is a scalar value. |
SpaceCurve[[from, to]] |
Takes the points lying in the X range from, to from the space curve. The result is a space curve. |
SpaceCurve[[Series]] |
Takes the points with the X values specified in Series from the space curve. The result is a space curve. |
Available in
FlexPro View, Basic, Professional, Developer Suite
Examples
DataSeries[0n] |
Takes the first element from a data series. |
DataSeries[-1n] |
Takes the last element from a data series. |
DataSeries[100n, -1n] or Data Series[100n, Empty] |
Takes all values from a data series starting at the 101st value. |
Data Series[0n, 100n] or Data Series[Empty, 100n] |
Takes the first 101 values from a data series. |
Signal[(NumberOfRows(Signal) / 2, 0n, 2n)] |
Takes every second point from a signal. |
Signal[(NumberOfRows(Signal), -1n, -1n)] |
Reverses the sequence of all points of a signal. |
SignalSeries[Sort(SignalSeries, SORT_Z + SORT_INDEX)] |
Re-sorts a signal series so that the Z component is increasing. |
DataMatrix[ ][0n] |
Takes the first row from a data matrix. |
Data Series[2 Pi] |
Takes the seventh element from a data series, since the unit Pi has the SI dimension 1 and 2 Pi transformed to the unit 1 results in 6.2831853 and is rounded as 6. |
DataMatrix[{ {1, 0}, {0, 1} }] |
Takes two values from a data matrix. Corresponds to { DataMatrix[1][0], DataMatrix[0][1] }. |