Reshape (FPScript)
Changes the dimension lengths and/or number of dimensions of a data series or a data matrix.
Syntax
Reshape(DataSet [ , Shape ])
The syntax of the Reshape function consists of the following parts:
Part |
Description |
---|---|
DataSet |
The data set for which the dimension lengths and or number of dimensions are to be changed. Permitted data structures are data series, data matrix, signal, signal series, signal series with two-dimensional X-component und space curve. All data types are permitted. If the argument is a list, then the function is executed for each element of the list and the result is also a list. |
Shape |
A data series with a maximum of two values, which specify the dimension lengths for the individual dimensions of the result. If DataSet is a data matrix, you can omit this argument. The data matrix is then converted into a data series. For an aggregate data structure, only the Y component is processed and all other components are discarded. Permitted data structures are scalar value und data series. All real data types are permitted. If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated. |
Remarks
The result has the same unit as the argument DataSet.
With this function, you can restructure a data matrix, transform a data matrix into a data series or, conversely, transform a data series into a data matrix. The total number of values of the result, which corresponds to the product of the value in Shape, must not be greater than that of DataSet. If this is smaller, then surplus values are discarded.
If Shape contains two values, then the result is a data matrix. The first value in Shape specifies the number of columns and the second specifies the number of rows. The data type of the result corresponds to that of DataSet.
Available in
FlexPro View, Basic, Professional, Developer Suite
Examples
Reshape({1, 2, 3, 4, 5, 6}, {2, 3}) |
Results in {{1, 2, 3}, {4, 5, 6}}. |
Reshape({1, 2, 3} # 2) |
Results in {1, 2, 3, 1, 2, 3}. |
Reshape(TransposeMatrix({Series, (0 # NumberOfRows(Series))}), {NumberOfRows(Series) * 2}) |
Inserts a zero at every second position in a data series. First, a data matrix is created using the Bundle operator for which the second column only contains zeros. This is then transposed, which places the data in memory into the desired sequence. Finally, the matrix is converted back into a data series. |