Indexed Assignment (FPScript)

23.08.2021

Assigns a new value to a section of a data set.

Syntax

Term Index1[Index2] = Expression

where Index1 stands for the following variants:

[]

or

[Index]

or

[from, to]

or

[[ ]]

or

[[ValueIndex]]

or

[[ValueFrom, ValueTo]]

and Index2 stands for the following variants:

[Index]

or

[from, to]

or

[[ValueIndex]]

or

[[ValueFrom, ValueTo]]

The syntax of the Indexed Assignment consists of the following elements:

Element

Description

Term

An expression that denotes a variable or a component or a list element in it. In the target determined this way, the indexed assignment replaces part of the data.

Index

Specifies the number(s) of the value(s) to be indexed. Can be an integral scalar value or a data series with integral values.

From

Specifies the index of the first value of a range to be indexed. Must be an integral scalar value.

to

Specifies the index of the last value of a range to be indexed. Must be an integral scalar value.

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.

Expression

Any expression with a scalar value or another data structure that must match the indexed section exactly. Depending on the index, the expression must be a scalar value, a data series or a data matrix. If you specify a scalar value, then this is assigned to all indexed elements in the data set.

Remarks

By using single brackets to write Index, you address the data to be changed by their indices. When you apply the indexed assignment to a signal, signal series, or space curve, only the Y component is considered, unless you explicitly address the X or Z component with the component operator.

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. With a two-dimensional data matrix, you can specify two indices consecutively. The first index then refers to the data series in the data matrix and the optional second index to the values in the data series extracted using the first index. If you leave the first index blank or specify Index as the Boolean value TRUE, then this indexes all data series.

As the syntax shows, you can specify the index in three variations: If you specify a scalar value (scalar value index) in the index, the index takes 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 elements listed in the data series or the elements in the range are taken. The rank of the result corresponds to the rank of the expression to be indexed.

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.

If ValueIndex is written with double brackets, the indexing does not happen via indices, but instead via X or Z values. Accordingly, the data set must have a composite data structure. Signal series with a two-dimensional X component are not supported. If the specified X or Z values do not occur exactly in the data set, 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 function SearchValue tab. 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.

The Expression data type is adapted before the assignment to the Term data type, if applicable.

If Term and Expression are quantities, then they have to have the same SI dimension and the unit of Expression is transformed before being assigned to the unit of Term. If only Term is a quantity, then the same unit is used for Expression. If only Expression is a quantity and the unit monitoring is set to Strict, then an error message will appear. Otherwise, the unit is ignored.

If Term is a list, then the index operation is carried out by element and the result is also a list. In this case Expression, Index1 and Index2 can also be specified as a list.

Note: 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 combinations except for the hybrid cases:

Data Structure

Permitted Operations

DataSeries[ScalarValue] = ScalarValue

Overwrites the value with the number specified in ScalarValue from the data series.

DataSeries[from, to] = DataSeries or ScalarValue

Overwrites the values lying in the range from, to from the data series.

DataSeries[Series] = DataSeries or ScalarValue

Overwrites the values specified in Series from the data series.

Signal[ScalarValue] = ScalarValue

Overwrites the value with the number specified in ScalarValue in the Y component of the signal.

Signal[from, to] = Signal, DataSeries or ScalarValue

Overwrites the signal values lying in the range from, to.

Signal[Series] = Signal, DataSeries or ScalarValue

Overwrites the signal values specified in Series.

SpaceCurve[ScalarValue] = ScalarValue

Overwrites the value with the number specified in ScalarValue in the Y component of the space curve.

SpaceCurve[from, to] = SpaceCurve, Signal, DataSeries or ScalarValue

Overwrites the values in the range from, to in the space curve.

SpaceCurve[Series] = SpaceCurve, Signal, DataSeries or ScalarValue

Overwrites the values specified in Series in the space curve.

DataMatrix[ScalarValue] = DataSeries or ScalarValue

Overwrites the column with the number specified in ScalarValue from the data matrix.

DataMatrix[from, to] = DataMatrix or ScalarValue

Overwrites the columns lying in the range from, to from the data matrix.

DataMatrix[Series] = DataMatrix or ScalarValue

Overwrites the columns specified in Series from the data matrix.

DataMatrix[][ScalarValue] = DataSeries or ScalarValue

Overwrites the row with the number specified in ScalarValue from the data matrix.

DataMatrix[][from, to] = DataMatrix or ScalarValue

Overwrites the rows lying in the range from, to from the data matrix.

DataMatrix[][Series] = DataMatrix or ScalarValue

Overwrites the rows specified in Series from the data matrix.

DataMatrix[ScalarValue1][ScalarValue2] = ScalarValue

Overwrites the value with the column specified in ScalarValue1 and the row specified with ScalarValue2 from the data matrix.

DataMatrix[ScalarValue][from, to] = DataSeries or ScalarValue

Overwrites the values lying in the range from, to from the column specified in ScalarValue from the data matrix.

DataMatrix[ScalarValue][Series] = DataSeries or ScalarValue

Overwrites the values specified in Series from the column specified in ScalarValue from the data matrix.

DataMatrix[from, to][ScalarValue] = DataSeries or ScalarValue

Overwrites the value specified in ScalarValue from the columns lying in the range from, to from the data matrix.

DataMatrix[from1, to1][from2, to2] = DataMatrix or ScalarValue

Overwrites the rows lying in the range from2, to2 from the columns lying in the range from1, to1 from the data matrix.

DataMatrix[from, to][Series] = DataMatrix or ScalarValue

Overwrites the rows specified in Series from the columns lying in the range from, to from the data matrix.

DataMatrix[Series][ScalarValue] = DataSeries or ScalarValue

Overwrites the value specified in ScalarValue from the columns specified in Series from the data matrix.

DataMatrix[Series][from, to] = DataMatrix or ScalarValue

Overwrites the rows lying in the range from, to from the columns listed in Series from the data matrix.

DataMatrix[Series1][Series2] = DataMatrix or ScalarValue

Overwrites the rows listed in Series2 from the columns listed in Series1 from the data matrix.

SignalSeries[ScalarValue] = Signal, DataSeries or ScalarValue

Overwrites the column with the number specified in ScalarValue in the signal series.

SignalSeries[from, to] = Signal, DataMatrix or ScalarValue

Overwrites the columns in the range from, to in the signal series.

SignalSeries[Series] = Signal, DataMatrix or ScalarValue

Overwrites the columns specified in Series in the signal series.

SignalSeries[][ScalarValue] = Signal, DataSeries or ScalarValue

Overwrites the row with the number specified in ScalarValue in the signal series.

SignalSeries[][from, to] = SignalSeries, DataMatrix or ScalarValue

Overwrites the rows in the range from, to in the signal series.

SignalSeries[][Series] = SignalSeries, DataMatrix or ScalarValue

Overwrites the rows specified in Series in the signal series.

SignalSeries[ScalarValue1][ScalarValue2] = ScalarValue

Overwrites the value with the column specified in ScalarValue1 and the row specified with ScalarValue2 in the Y component of the signal series.

SignalSeries[ScalarValue][from, to] = Signal, DataSeries or ScalarValue

Overwrites the values lying in the range from, to from the column specified in ScalarValue in the signal series.

SignalSeries[ScalarValue][Series] = Signal, DataSeries or ScalarValue

Overwrites the values specified in Series from the column specified in Scalar Value from the signal series.

SignalSeries[from, to][ScalarValue] = Signal, DataSeries or ScalarValue

Overwrites the value specified in ScalarValue from the columns lying in the range from, to from the signal series.

SignalSeries[from1, to1][from2, to2] = SignalSeries, DataMatrix or ScalarValue

Overwrites the rows lying in the range from2, to2 from the columns lying in the range from1, to1 from the signal series.

SignalSeries[from, to][Series] = SignalSeries, DataMatrix or ScalarValue

Overwrites the rows specified in Series from the columns lying in the range from, to from the signal series.

SignalSeries[Series][ScalarValue] = Signal, DataSeries or ScalarValue

Overwrites the value specified in Scalar Value from the columns specified in Series in the signal series.

SignalSeries[Series][from, to] = SignalSeries, DataMatrix or ScalarValue

Overwrites the rows in the range from, to from the columns listed in Series from the signal series.

SignalSeries[Series1][Series2] = SignalSeries, DataMatrix or ScalarValue

Overwrites the rows specified in Series2 from the columns listed in Series1 from the signal series.

Signal[[ScalarValue]] = ScalarValue

Overwrites the Y value with the X value specified in ScalarValue in the signal.

Signal[[from, to]] = Signal, DataSeries or ScalarValue

Overwrites the Y values in the range from, to in the signal.

Signal[[Series]] = Signal, DataSeries or ScalarValue

Overwrites the values with the X values specified in Series in the signal.

SpaceCurve[[ScalarValue]] = ScalarValue

Overwrites the Y value with the X value specified in ScalarValue in the space curve.

SpaceCurve[[from, to]] = SpaceCurve, Signal, DataSeries or ScalarValue

Overwrites the values in the X range from, to in the space curve.

SpaceCurve[[Series]] = SpaceCurve, Signal, DataSeries or ScalarValue

Overwrites the values with the X values specified in Series in the space curve.

SignalSeries[[ScalarValue]] = Signal, DataSeries or ScalarValue

Overwrites the column with the X value specified in ScalarValue in the signal series.

SignalSeries[[from, to]] = SignalSeries, DataMatrix or ScalarValue

Overwrites the columns with the X values in the range from, to in the signal series.

SignalSeries[[Series]] = SignalSeries, DataMatrix or ScalarValue

Overwrites the columns with the X values specified in Series in the signal series.

SignalSeries[[]][[ScalarValue]] = Signal, DataSeries or ScalarValue

Overwrites the row with the Z value specified in ScalarValue in the signal series.

SignalSeries[[]][[from, to]] = SignalSeries, DataMatrix or ScalarValue

Overwrites the rows with the X values in the range from, to in the signal series.

SignalSeries[[]][]Series]] = SignalSeries, DataMatrix or ScalarValue

Overwrites the rows with the X values specified in Series in the signal series.

SignalSeries[[ScalarValue1]][[ScalarValue2]] = ScalarValue

Overwrites the Y value in the X value specified in ScalarValue1 and the Z value specified in ScalarValue2 in the signal series.

SignalSeries[[ScalarValue]][[from, to]] = Signal, DataSeries or ScalarValue

Overwrites the values with the X values in the range from, to in the column with the Z value specified in ScalarValue in the signal series.

SignalSeries[[ScalarValue]][[Series]] = Signal, DataSeries or ScalarValue

Overwrites the values with the Y values specified in Series in the column with the X value specified in ScalarValue in the signal series.

SignalSeries[[from, to]][[ScalarValue]] = Signal, DataSeries or ScalarValue

Overwrites the values with the X value specified in ScalarValue in columns with the Z values in the range from, to from the signal series.

SignalSeries[[from1, to1]][[from2, to2]] = SignalSeries, DataMatrix or ScalarValue

Overwrites the values with the X values in the range from2, to2 in columns with the Z values in the range from1, to1 from the signal series.

SignalSeries[[from, to]][[Series]] = SignalSeries, DataMatrix or ScalarValue

Overwrites the values with the X values listed in Series in columns with the Z values in the range from, to from the signal series.

SignalSeries[[Series]][[ScalarValue]] = Signal, DataSeries or ScalarValue

Overwrites the values with the X value specified in ScalarValue in columns with the Z values listed in Series in the signal series.

SignalSeries[[Series]][[from, to]] = SignalSeries, DataMatrix or ScalarValue

Overwrites the values with the X values in the range from, to in columns with the Z values listed in Series in the signal series.

SignalSeries[[Series1]][[Series2]] = SignalSeries, DataMatrix or ScalarValue

Overwrites the values with the X values listed in Series2 in columns with the Z values listed in Series1 in the signal series.

Available in

FlexPro View, Basic, Professional, Developer Suite

Examples

List.[1n][0n, 99n] = ?

Sets the first 100 elements in the data series, found in the second element of the list saved in the List variable, to void.

Signal[-3n, -1n] = { 3.5, 4.8, 1.2 }

Changes the last three values in the Y component from Signal.

Signal.X[0n] = 1

Sets the first X value in Signal to the value 1.

Signal[[1.2 s, 5.4 s]] = 0

Sets all Y values in the X range from 1.2 s to 5.4 s in the signal to the value 0.

Series[{1n, 2n, -1n}] = ?

Sets the second, third and last value in Series to void.

DataMatrix[][0n] = Row

Replaces the first row in DataMatrix with the values in the data series Row.

 

See Also

Index Operator

Assignment

Share article or send as email:

You might be interested in these articles