Select subset of rows or columns from input
The Variable Selector block extracts a subset of rows or columns from the M-by-N input matrix u at each input port. You specify the number of input and output ports in the Number of input signals parameter.
When the Select parameter is set to Rows, the Variable Selector block extracts rows from each input matrix, while if the Select parameter is set to Columns, the block extracts columns.
When the Selector mode parameter is set to Variable, the length-L vector input to the Idx port selects L rows or columns of each input to pass through to the output. The elements of the indexing vector can be updated at each sample time, but the vector length must remain the same throughout the simulation.
When the Selector mode parameter is set to Fixed, the Idx port is disabled, and the length-L vector specified in the Elements parameter selects L rows or columns of each input to pass through to the output. The Elements parameter is tunable, so you can change the values of the indexing vector elements at any time during the simulation; however, the vector length must remain the same.
For both variable and fixed indexing modes, the row selection operation is equivalent to
y = u(idx,:) % Equivalent MATLAB code
and the column selection operation is equivalent to
y = u(:,idx) % Equivalent MATLAB code
where idx is the length-L indexing vector. The row selection output size is L-by-N and the column selection output size is M-by-L. Input rows or columns can appear any number of times in the output, or not at all.
When the input is an unoriented vector, the Select parameter is ignored; the output is a unoriented vector of length L containing those elements specified by the length-L indexing vector.
When an element of the indexing vector references a nonexistent row or column of the input, the block reacts with the action you specify using the Invalid index parameter.
When the indexing vector elements are of Boolean data type, the block performs logical indexing. Select Fill empty spaces in outputs (for logical indexing) to access the Fill values parameter. These values are appended to the output to make it as long as the input elements.
Specify the number of input signals. An input port is created on the block for each input signal.
Specify the dimension of the input to select, Rows or Columns.
Specify the type of indexing operation to perform, Variable or Fixed. Variable indexing uses the input at the Idx port to select rows or columns from the input at the In port. Fixed indexing uses the Elements parameter value to select rows from the input at the In port, and disables the Idx port.
Specify a vector containing the indices of the input rows or columns that will appear in the output matrix. This parameter appears only when you set the Selector mode to Fixed.
When set to One-based, an index value of 1 refers to the first row or column of the input. When set to Zero-based, an index value of 0 refers to the first row or column of the input.
Specify how the block handles an invalid index value. You can select one of the following options:
Clip index — Clip the index to the nearest valid value, and do not issue an alert.
For example, if the block receives a 64-by-4 input and the Select parameter is set to Rows, the block clips an index of 72 to 64. For the same input, if the Select parameter is set to Columns, the block clips an index of 72 to 4. In both cases, the block clips an index of -2 to 1.
Clip and warn — Clip the index to the nearest valid value and display a warning message at the MATLAB® command line.
Generate error — Display an error dialog box and terminate the simulation.
This parameter is tunable.
When the indexing vector elements are of Boolean data type, the block performs logical indexing. This can cause empty spaces in the output. Select this parameter to designate values to be appended to the output in the Fill values parameter.
Specify the fill values when the block performs logical indexing. This parameter appears only when you select the Fill empty spaces in outputs (for logical indexing) check box.
This block supports HDL code generation using HDL Coder™. HDL Coder provides additional configuration options that affect HDL implementation and synthesized logic. For more information on implementations, properties, and restrictions for HDL code generation, see Variable Selector.
|Port||Supported Data Types|