# Submatrix

Select subset of elements (submatrix) from matrix input

Libraries:

## Description

The Submatrix block extracts a contiguous submatrix, y, from the M-by-N input matrix `u`. For more information about selecting the rows and columns to extract, see Range Specification Options.

## Examples

expand all

This example shows how to use the Submatrix block to extract a 3-by-2 submatrix from the lower-right corner of a 5-by-7 input matrix. The following figure illustrates the operation of the Submatrix block with a 5-by-7 input matrix of random integer elements, `randi([0 9],5,7)`.

Here are the settings used for the `Submatrix` block in this example.

There are often several possible parameter combinations that you can use to select the same submatrix from the input. For example, in the case of a 5-by-7 input matrix, instead of specifying `Last` for Ending column, you could select the same submatrix by specifying:

• Ending column = `Index`

• Ending column index = `7`

Open and simulate the model. You can see that the 3-by-2 submatrix from the lower-right corner of a 5-by-7 input matrix has been extracted.

## Ports

### Input

expand all

Input signal, from which the block extracts the specified submatrix.

This block supports Simulink® virtual buses.

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

### Output

expand all

Submatrix selected from the input signal. The data type of the output is the same as the input.

This block supports Simulink virtual buses.

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

## Parameters

expand all

For more information about selecting the subset of elements to form the submatrix, see Range Specification Options.

The range of input rows to be retained in the output.

The input row to be used as the first and only row of the output.

#### Dependencies

To enable this parameter, set Row span to `One row`.

The input row to be used as the first row of the output.

#### Dependencies

To enable this parameter, set Row span to `Range of rows`.

The index of the input row to be used as the first and only row of the output, specified as an integer greater than or equal to one.

#### Dependencies

To enable this parameter, set Row span to `One row` and Row to `Index`.

The index of the input row to be used as the first row of the output, specified as an integer greater than or equal to one.

#### Dependencies

To enable this parameter, set Row span to `Range of rows` and Starting row to `Index`.

The offset of the input row to be used as the first and only row of the output, specified as an integer greater than or equal to one.

#### Dependencies

To enable this parameter, set Row span to `One row` and Row to `Offset from last` or ```Offset from middle```.

The offset of the input row to be used as the first row of the output, specified as an integer greater than or equal to one.

#### Dependencies

To enable this parameter, set Row span to `Range of rows` and Starting row to `Offset from last` or `Offset from middle`.

The input row to be used as the last row of the output.

#### Dependencies

To enable this parameter, set Row span to `Range of rows` and set Starting row to any value except `Last`.

The index of the input row to be used as the last row of the output, specified as an integer greater than or equal to one.

#### Dependencies

To enable this parameter, set Ending row to `Index`.

The offset of the input row to be used as the last row of the output.

#### Dependencies

To enable this parameter, set Ending row to `Offset from middle` or ```Offset from last```.

The range of input columns to be retained in the output.

The input column to be used as the first and only column of the output.

#### Dependencies

To enable this parameter, set Column span to `One column`.

The input column to be used as the first column of the output.

#### Dependencies

To enable this parameter, set Column span to `Range of columns`.

The index of the input column to be used as the first column of the output, specified as an integer greater than or equal to one.

#### Dependencies

To enable this parameter, set Column span to `Range of columns` and Starting column to `Index`.

The index of the input column to be used as the first and only column of the output, specified as an integer greater than or equal to one.

#### Dependencies

To enable this parameter, set Column span to `One column` and Column to `Index`.

The offset of the input column to be used as the first and only column of the output, specified as an integer greater than or equal to one.

#### Dependencies

To enable this parameter, set Column span to `One column` and Column to ```Offset from last``` or ```Offset from middle```.

The offset of the input column to be used as the first column of the output, specified as an integer greater than or equal to one.

#### Dependencies

To enable this parameter, set Column span to `Range of columns` and Starting column to `Offset from last` or `Offset from middle`.

The input column to be used as the last column of the output.

#### Dependencies

To enable this parameter, set Column span to `Range of columns` and set Starting column to any value except `Last`.

The index of the input column to be used as the last column of the output, specified as an integer greater than or equal to one.

#### Dependencies

To enable this parameter, set Ending column to `Index`.

The offset of the input column to be used as the last column of the output.

#### Dependencies

To enable this parameter, set Ending column to `Offset from middle` or ```Offset from last```.

## Block Characteristics

 Data Types `Boolean` | `double` | `enumerated` | `fixed point` | `integer` | `single` Direct Feedthrough `no` Multidimensional Signals `no` Variable-Size Signals `no` Zero-Crossing Detection `no`

expand all

## Version History

Introduced before R2006a

expand all