Selector
Selects the given elements from the input vector, matrix or multidimensional array.
blockType: Selector
Path in the library:
|
Description
The Selector block extracts selected elements of an input vector, matrix or multidimensional array based on specified indices. The extracted signals can be grouped differently than the input signals.
Depending on the value of the parameter Number of input dimensions the table of indexing parameters changes. Each row of the table corresponds to one of the input measurements in Number of input dimensions. An input signal must have no more than a certain number of measurements, specified as Number of input dimensions. For example, if Number of input dimensions equals , then the signal will be interpreted as -dimensional. For example, if the input is expected to be a scalar (one-dimensional) but Number of input dimensions equals 2
, the scalar will be treated as two-dimensional. When configuring the Selector block for operations with multidimensional signals, the block icon changes.
Suppose we have an array of numbers U
and we want to select a subarray Y
of U
using some numeric value Idx1
as an index.
Suppose we have an array U
:
U = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
We want to select a subarray Y
of size 8
from U
, starting from the element with index Idx1
:
Idx1 = 3
Y = U[Idx1:Idx1+7]
This means that we select elements with indices 3
to 10
from U
. Thus, Y
will contain the following values:
Y = [3, 4, 5, 6, 7, 8, 9, 10]
Here Y
is a subarray of U
starting from the third element and including the next 7
elements after it. Idx1
defines the initial index of the second dimension, and Idx1+7
defines the final index of the second dimension.
The Selector block uses similar behaviour to the getindex function in Julia (see Indexing for details ).
|
Parameters for the first index are given in the parameter group Index 1. The number of parameter groups depends on the number of dimensions (value of parameter Number of input dimensions). The set of parameters for each index is the same, they differ only in the name for programme code (the number at the end of the name means the index number).
Ports
Output
#
Y
—
output signal
scalar
| vector
| matrix
| multidimensional array
Details
An output signal composed of selected and/or reordered elements of the input signal.
Data types |
|
Complex numbers support |
Yes |
Input
#
U
—
input signal
scalar
| vector
| matrix
| multidimensional array
Details
The input signal from which elements are taken for the output signal.
Data types |
|
Complex numbers support |
Yes |
#
IdxNind
—
port for setting the Nth index
scalar
| vector
| matrix
Details
An external port specifying an index to select the corresponding output element. Fractional values within a block are rounded to integers.
The name of the port depends on which index it refers to and on the value of the parameters Index mode.
If the parameter Index mode is set to . One-based`then the index in the port name is `1
, if the value is Zero-based`then it is `0
.
Dependencies
To use an external index port, set the parameters of the corresponding index Index option to 1
. Index vector (port)
, Starting index (port)
.
Data types |
|
Complex numbers support |
No |
Parameters
Parameters
#
Number of input dimensions —
number of dimensions to be processed
Real number
Details
Sets the number of dimensions ( ) of the input signal to be processed.
The maximum number of dimensions is 32
.
*Example:
The input vector has one dimension, but you want to represent it as a two-dimensional array. Suppose there is a vector with three elements, which by default is represented as one-dimensional and has dimension (3,)
.
In this case, the block uses the getindex
function with indices FirstIndices
and SecondIndices
according to the signature getindex(U, FirstIndices, SecondIndices)
:
julia> getindex(a, [1,2], :)
2x1 Matrix{Int64}:
1
2
Vector a
contains the values [1, 2, 3]
. Using the getindex
function with parameters [1, 2]
and :
, the block selects elements from vector a
on the first dimension with indices 1
and 2
, and uses all elements (represented by :
) on the second dimension. The result will be a matrix of size 2x1 containing elements of vector a
with indices 1
and 2
.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
#
Index mode —
indexing mode
Zero-based
| One-based
Details
Sets the indexing mode:
-
One-based
- the first element of the input vector has index1
.Example: if the input vector contains values
[0 5 10 20 50 100]
and you want to select an element with index3
, the output should be the value10
. -
Zero-based
- the first element of the input vector has index0
.Example: if the input vector contains the values
[0 5 10 20 50 50 100]
and you need to select an element with index3
, then the output should be the value20
.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
#
Input port size —
input signal width
Integer
Details
Set the block input signal width for one-dimensional signals. Enter -1
to inherit from the control block.
When working with vector rows (matrices of size 1 by ) and vector columns (matrices of size by 1) it is possible to set the number of dimensions (value of the parameter Number of input dimensions) equal to 1 . In this case, you should set the value of the parameter Input port size correctly. It is possible to select elements from such arrays using one index.
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |