| 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:
Specifies that y contains only one row from u. The Starting row parameter (described below) is enabled to allow selection of the desired row.
Specifies that 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:
For rows, this specifies that the first row of 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).
For rows, this specifies that the row of 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).
For rows, this specifies that the row of 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).
For rows, this specifies that the last row of 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).
For rows, this specifies that the row of 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).
For rows, this specifies that the middle row of 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:
For rows, this specifies that the row of 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).
For rows, this specifies that the row of 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).
For rows, this specifies that the last row of 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).
For rows, this specifies that the row of 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).
For rows, this specifies that the middle row of 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:
Range of rows
Index
3
Last
Range of columns
Offset from last
1
Last
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.
All rows, One row, or Range of rows.
One row is selected from Row span, and Starting row when Range of rows is selected from Row span.
Index is selected from Row, and Starting row index when Index is selected from Starting row.
Offset from middle or Offset from last is selected from Row, and Starting row offset is enabled when Offset from middle or Offset from last is selected from Starting row.
Range of rows is selected from Row span and any option but Last is selected from Starting row.
Index is selected from Ending row.
Offset from middle or Offset from last is selected from Ending row.
All columns, One column, or Range of columns.
One column is selected from Column span, and Starting column is enabled when Range of columns is selected from Column span.
Index is selected from Column, and Starting column index is enabled when Index is selected from Starting column.
Offset from middle or Offset from last is selected from Column. Starting column offset is enabled when Offset from middle or Offset from last is selected from Starting column.
Range of columns is selected from Column span and any option but Last is selected from Starting column.
Index is selected from Ending column.
Offset from middle or Offset from last is selected from Ending column.
Supported Data Types
To learn how to convert your data types 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.
| Standard Deviation | SVD Solver | ![]() |
Learn more about the latest releases of MathWorks products: |
| © 1994-2009 The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |