DSP Blockset | ![]() ![]() |
Select a subset of elements (submatrix) from a matrix input.
Library
Description
The Submatrix block extracts a contiguous submatrix from the M-by-N input matrix u
. A length-M 1-D vector input is treated as an M-by-1 matrix. The Row span parameter provides three options for specifying the range of rows in u
to be retained in submatrix output y
:
y
contains only one row from u
. The Starting row parameter (described below) is enabled to allow selection of the desired row.
y
contains one or more rows from u
. The Row and Ending row parameters (described below) are enabled to allow selection of the desired range of rows.
The Column span parameter contains a corresponding set of three options for specifying the range of columns in u
to be retained in submatrix y
: All columns, One column, or Range of columns. The One column option enables the Column parameter, and Range of columns options enable the Starting column and Ending column parameters.
The output has the same frame status as the input.
Range Specification Options
When One row or Range of rows is selected from the Row span parameter, the desired row or range of rows is specified by the Row parameter, or the Starting row and Ending row parameters. Similarly, when One column or Range of columns is selected from the Column span parameter, the desired column or range of columns is specified by the Column parameter, or the Starting column and Ending column parameters.
The Row, Column, Starting row or Starting column can be specified in six ways:
u
should be used as the first row of y
. If all columns are to be included, this is equivalent to y(1,:) = u(1,:)
.
For columns, this specifies that the first column of u
should be used as the first column of y
. If all rows are to be included, this is equivalent to y(:,1) = u(:,1)
.
u
, firstrow
, forward-indexed by the Row index parameter or the Starting row index parameter, should be used as the first row of y
. If all columns are to be included, this is equivalent to y(1,:) = u(firstrow,:)
.
For columns, this specifies that the column of u
, forward-indexed by the Column index parameter or the Starting column index parameter, firstcol
, should be used as the first column of y
. If all rows are to be included, this is equivalent to y(:,1) = u(:,firstcol)
.
u
offset from row M by the Row offset or Starting row offset parameter, firstrow
, should be used as the first row of y
. If all columns are to be included, this is equivalent to y(1,:) = u(M-firstrow,:)
.
For columns, this specifies that the column of u
offset from column N by the Column offset or Starting column offset parameter, firstcol
, should be used as the first column of y
. If all rows are to be included, this is equivalent to y(:,1) = u(:,N-firstcol)
.
u
should be used as the only row of y
. If all columns are to be included, this is equivalent to y = u(M,:)
.
For columns, this specifies that the last column of u
should be used as the only column of y
. If all rows are to be included, this is equivalent to y = u(:,N)
.
u
offset from row M/2 by the Starting row offset parameter, firstrow
, should be used as the first row of y
. If all columns are to be included, this is equivalent to y(1,:) = u(M/2-firstrow,:)
.
For columns, this specifies that the column of u
offset from column N/2 by the Starting column offset parameter, firstcol
, should be used as the first column of y
. If all rows are to be included, this is equivalent to y(:,1) = u(:,N/2-firstcol)
.
u
should be used as the only row of y
. If all columns are to be included, this is equivalent to y = u(M/2,:)
.
For columns, this specifies that the middle column of u
should be used as the only column of y
. If all rows are to be included, this is equivalent to y = u(:,N/2)
.
The Ending row or Ending column can similarly be specified in five ways:
u
forward-indexed by the Ending row index parameter, lastrow
, should be used as the last row of y
. If all columns are to be included, this is equivalent to y(end,:) = u(lastrow,:)
.
For columns, this specifies that the column of u
forward-indexed by the Ending column index parameter, lastcol
, should be used as the last column of y
. If all rows are to be included, this is equivalent to y(:,end) = u(:,lastcol)
.
u
offset from row M by the Ending row offset parameter, lastrow
, should be used as the last row of y
. If all columns are to be included, this is equivalent to y(end,:) = u(M-lastrow,:)
.
For columns, this specifies that the column of u
offset from column N by the Ending column offset parameter, lastcol
, should be used as the last column of y
. If all rows are to be included, this is equivalent to y(:,end) = u(:,N-lastcol)
.
u
should be used as the last row of y
. If all columns are to be included, this is equivalent to y(end,:) = u(M,:)
.
For columns, this specifies that the last column of u
should be used as the last column of y
. If all rows are to be included, this is equivalent to y(:,end) = u(:,N)
.
u
offset from row M/2 by the Ending row offset parameter, lastrow
, should be used as the last row of y
. If all columns are to be included, this is equivalent to y(end,:) = u(M/2-lastrow,:)
.
For columns, this specifies that the column of u
offset from column N/2 by the Ending column offset parameter, lastcol
, should be used as the last column of y
. If all rows are to be included, this is equivalent to y(:,end) = u(:,N/2-lastcol)
.
u
should be used as the last row of y
. If all columns are to be included, this is equivalent to y(end,:) = u(M/2,:)
.
For columns, this specifies that the middle column of u
should be used as the last column of y
. If all rows are to be included, this is equivalent to y(:,end) = u(:,N/2)
.
Example
To extract the lower-right 3-by-2 submatrix from a 5-by-7 input matrix, enter the following set of parameters:
3
1
The figure below shows the operation for a 5-by-7 matrix with random integer elements, randint(5,7,10)
.
There are often several possible parameter combinations that select the same submatrix from the input. For example, instead of specifying Last for Ending column, you could select the same submatrix by specifying:
Dialog Box
The parameters displayed in the dialog box vary for different menu combinations. Only some of the parameters listed below are visible in the dialog box at any one time.
Supported Data Types
To learn how to convert to the above data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.
See Also
Reshape |
Simulink |
Selector |
Simulink |
Variable Selector |
DSP Blockset |
reshape |
MATLAB |
See Deconstructing Signals for related information. Also see Matrix Operations and Indexing for a list of all the blocks in these libraries.
![]() | Standard Deviation | SVD Solver | ![]() |