Documentation

Selector

Select input elements from vector, matrix, or multidimensional signal

  • Library:
  • Simulink / Signal Routing

Description

TheSelectorblock generates as output selected or reordered elements of an input vector, matrix, or multidimensional signal.

Based on the value you enter for theNumber of input dimensionsparameter, a table of indexing settings is displayed. Each row of the table corresponds to one of the input dimensions inNumber of input dimensions. For each dimension, you define the elements of the signal to work with. Specify a vector signal as a 1-D signal and a matrix signal as a 2-D signal. When you configure theSelectorblock for multidimensional signal operations, the block icon changes.

For example, assume a 6-D signal with a one-based index mode. The table of the Selector block dialog changes to include one row for each dimension. If you define dimensions with these entries:

Row Index Option Index Output Size
1 Select all
2 Starting index (dialog) 2 5
3 Index vector (dialog) [1 3 5]
4 Starting index (port) 8
5 Index vector (port)
6 Starting and ending indices (port)

The output will beY=U(1:end,2:6,[1 3 5],Idx4:Idx4+7,Idx5, Idx6(1):Idx6(2)), whereIdx4,Idx5, andIdx6are the index ports for dimensions 4, 5, and 6.

You can use an array of buses as an input signal to a Selector block. For details about defining and using an array of buses, seeCombine Buses into an Array of Buses.

Ports

Input

expand all

Input signal and source of elements to output signal.

Data Types:single|double|int8|int16|int32|uint8|uint16|uint32|Boolean|fixed point|enumerated|bus

External port specifying an index for the selection of the corresponding output element.

Dependencies

使外部索引端口,一ding row of theIndex Optiontable, setIndex OptiontoIndex vector (port),Starting index (port), orStarting and ending indices (port).

Data Types:single|double|int8|int16|int32|uint8|uint16|uint32|fixed point|enumerated

Output

expand all

Output signal generated from selected or reordered elements of input signal.

Data Types:single|double|int8|int16|int32|uint8|uint16|uint32|Boolean|fixed point|enumerated|bus

Parameters

expand all

Specifies the number of dimensions of the output signal.

Command-Line Information

Parameter:NumberOfDimensions
Type:character vector
Values:integer
Default:'1'

Specifies the indexing mode. IfOne-based是selected, an index of 1 specifies the first element of the input vector. IfZero-based是selected, an index of 0 specifies the first element of the input vector.

Defines, by dimension, how the elements of the signal are to be indexed. From the list, select:

  • Select all

    No further configuration is required. All elements are selected.

  • Index vector (dialog)

    Enables theIndexcolumn. Enter the vector of indices of the elements.

  • Index vector (port)

    No further configuration is required.

  • Starting index (dialog)

    Enables theIndexandOutput Sizecolumns. Enter the starting index of the range of elements to select in theIndexcolumn and the number of elements to select in theOutput Sizecolumn.

  • Starting index (port)

    Enables theOutput Sizecolumn. Enter the number of elements to be selected in theOutput Sizecolumn.

  • Starting and ending indices (port)

    No further configuration is required.

    Using this option results in a variable-size output signal. When you update, the output dimension is set to be the same as the input signal dimension. During execution, the output dimension is updated based on the signal feeding the index.

    When logging output signal data, signals not selected are padded with NaN values.

TheIndexandOutput Sizecolumns appear as needed.

Command-Line Information

Parameter:IndexOptionArray
Type:character vector
Values:'Select all'|'Index vector (dialog)'|'Index option (port)'|'Starting index (dialog)'|'Starting index (port)'|Starting and ending indices (port)
Default:'Index vector (dialog)'

If theIndex OptionIndex vector (dialog), enter the index of each element you are interested in.

If theIndex OptionStarting index (dialog), enter the starting index of the range of elements to be selected.

Command-Line Information

Parameter:IndexParamArray
Type:character vector
Values:cell array
Default:'{ }'

Specifies the width of the block output signal.

Command-Line Information

Parameter:OutputSizeArray
Type:character vector
Values:cell array
Default:'{ }'

Specify the width of the block input signal for 1-D signals. Enter-1to inherit from the driving block.

Command-Line Information

Parameter:InputPortWidth
Type:character vector
Values:integer
Default:'1'

Specify the sample time as a value other than -1. For more information, seeSpecify Sample Time.

Dependencies

This parameter is not visible unless it is explicitly set to a value other than-1. To learn more, seeBlocks for Which Sample Time Is Not Recommended.

Programmatic Use

Block Parameter:SampleTime
Type:character vector
Values:scalar
Default:'-1'

Block Characteristics

Data Types

double|single|Boolean|base integer|fixed point|enumerated

Multidimensional Signals

Yes

Variable-Size Signals

Yes

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Fixed-Point Conversion
Convert floating-point algorithms to fixed point using Fixed-Point Designer™.

Introduced before R2006a

Was this topic helpful?