Select subset of elements (submatrix) from matrix input
Math Functions / Matrices and Linear Algebra / Matrix Operations
dspmtrx3
Signal Management / Indexing
dspindex
The Submatrix block extracts a contiguous submatrix from the MbyN input
matrix u
. The block treats lengthM unoriented
vector input as an Mby1
matrix.
The Row span parameter provides three options
for specifying the range of rows in u
to be retained
in submatrix output y
:
All rows
Specifies that y
contains all M rows
of u
.
One row
Specifies that y
contains only one row from u
.
The Row parameter (described below) is enabled
to allow selection of the desired row.
Range of rows
Specifies that y
contains one or more rows
from u
. The Starting 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.
When you select One row
or Range
of rows
from the Row span parameter,
you specify the desired row or range of rows in the Row parameter,
or the Starting row and Ending row parameters.
Similarly, when you select One column
or Range
of columns
from the Column span parameter,
you specify the desired column or range of columns in 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:
First
For rows, this specifies that the first row of u
should
be used as the first row of y
. When 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
. When all rows
are to be included, this is equivalent to y(:,1) = u(:,1)
.
Index
For rows, this specifies that the row of u
, firstrow
,
forwardindexed by the Row index parameter or
the Starting row index parameter, should be used
as the first row of y
. When all columns are to
be included, this is equivalent to y(1,:) = u(firstrow,:)
.
For columns, this specifies that the column of u
,
forwardindexed by the Column index parameter
or the Starting column index parameter, firstcol
,
should be used as the first column of y
. When all
rows are to be included, this is equivalent to y(:,1) = u(:,firstcol)
.
Offset from last
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
. When all columns
are to be included, this is equivalent to y(1,:) = u(Mfirstrow,:)
.
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
. When all rows
are to be included, this is equivalent to y(:,1) = u(:,Nfirstcol)
.
Last
For rows, this specifies that the last row of u
should
be used as the only row of y
. When 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
. When all rows
are to be included, this is equivalent to y = u(:,N)
.
Offset from middle
When you select this option, the block selects the first row
or column of the output y
by adding the specified
offset to the middle row or column of the input u
.
When the number, X, of input rows or columns is
even, the block defines the middle one as X/2
+1. When the number of input rows or columns
is odd, the block defines the middle one as ceil
(X/2).
When all columns are to be included, the following code defines
the starting row: y(1,:) = u(MiddleRow+Offset,:)
,
where Offset
is the value of the Row
offset or Starting row offset parameter.
When all rows are to be included, the following code defines the starting
column: y(1,:) = u(:,MiddleColumn+Offset)
, where Offset
is
the value of the Column offset or Starting
column offset parameter.
Middle
When you select this option, the block uses the middle row or
column of the input u
as the first row or column
of the output y
. When the number, X,
of input rows or columns is even, the block defines the middle one
as X/2 +1.
When the number of input rows or columns is odd, the block defines
the middle one as ceil
(X/2).
When all columns are to be included, the following code defines
the starting row: y = u(MiddleRow,:)
. When all
rows are to be included, the following code defines the starting column: y
= u(:,MiddleColumn)
.
The Ending row or Ending column can similarly be specified in five ways:
Index
For rows, this specifies that the row of u
forwardindexed
by the Ending row index parameter, lastrow
,
should be used as the last row of y
. When all columns
are to be included, this is equivalent to y(end,:) = u(lastrow,:)
.
For columns, this specifies that the column of u
forwardindexed
by the Ending column index parameter, lastcol
,
should be used as the last column of y
. When all
rows are to be included, this is equivalent to y(:,end) =
u(:,lastcol)
.
Offset from last
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
. When all columns
are to be included, this is equivalent to y(end,:) = u(Mlastrow,:)
.
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
. When all
rows are to be included, this is equivalent to y(:,end) =
u(:,Nlastcol)
.
Last
For rows, this specifies that the last row of u
should
be used as the last row of y
. When 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
. When all rows
are to be included, this is equivalent to y(:,end) = u(:,N)
.
Offset from middle
When you select this option, the block selects the last row
or column of the output y
by adding the specified
offset to the middle row or column of the input u
.
When the number, X, of input rows or columns is
even, the block defines the middle one as X/2
+1. When the number of input rows or columns
is odd, the block defines the middle one as ceil
(X/2).
When all columns are to be included, the following code defines
the ending row: y(end,:) = u(MiddleRow+Offset,:)
,
where Offset
is the value of the Ending
row offset parameter. When all rows are to be included,
the following code defines the ending column: y(:,end) =
u(:,MiddleColumn+Offset)
, where Offset
is
the value of the Ending column offset parameter.
Middle
When you select this option, the block uses the middle row or
column of the input u
as the last row or column
of the output y
. When the number, X,
of input rows or columns is even, the block defines the middle one
as X/2 +1.
When the number of input rows or columns is odd, the block defines
the middle one as ceil
(X/2).
When all columns are to be included, the following code defines
the ending row: y(end,:) = u(MiddleRow,:)
. When
all rows are to be included, the following code defines the ending
column: y(:,end) = u(:,MiddleColumn)
.
This block supports Simulink^{®} virtual buses.
The ex_submatrix_ref model uses a Submatrix block to extract a 3by2 submatrix from the lowerright corner of a 5by7 input matrix.
The following figure shows the operation of the Submatrix block
with a 5by7 input matrix of random integer elements, randi([0
9],5,7)
.
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 5by7 input matrix, instead
of specifying Last
for Ending
column, you could select the same submatrix by specifying
Ending column = Index
Ending column index = 7
The range of input rows to be retained in the output. Options
are All rows
, One row
,
or Range of rows
.
The input row to be used as the first row of the output. Row is
enabled when you select One row
from Row
span, and Starting row when you select Range
of rows
from Row span.
The index of the input row to be used as the first row of the
output. Row index is enabled when you select Index
from
Row, and Starting row index when you select Index
from Starting
row.
The offset of the input row to be used as the first row of the
output. Row offset is enabled when you select Offset
from middle
or Offset from last
from Row,
and Starting row offset is enabled when you select Offset
from middle
or Offset from last
from Starting
row.
The input row to be used as the last row of the output. This
parameter is enabled when you select Range of rows
from Row
span and you select any option but Last
from Starting
row.
The index of the input row to be used as the last row of the
output. This parameter is enabled when you select Index
from Ending
row.
The offset of the input row to be used as the last row of the
output. This parameter is enabled when you select Offset
from middle
or Offset from last
from Ending
row.
The range of input columns to be retained in the output. Options
are All columns
, One column
,
or Range of columns
.
The input column to be used as the first column of the output. Column is
enabled when you select One column
from Column
span, and Starting column is enabled
when you select Range of columns
from Column
span.
The index of the input column to be used as the first column
of the output. Column index is enabled when you
select Index
from Column, and Starting
column index is enabled when you select Index
from Starting
column.
The offset of the input column to be used as the first column
of the output. Column offset is enabled when
you select Offset from middle
or Offset
from last
from Column. Starting
column offset is enabled when you select Offset
from middle
or Offset from last
from Starting
column.
The input column to be used as the last column of the output.
This parameter is enabled when you select Range of columns
from Column
span and you select any option but Last
from Starting
column.
The index of the input column to be used as the last column
of the output. This parameter is enabled when you select Index
from Ending
column.
The offset of the input column to be used as the last column
of the output. This parameter is enabled when you select Offset
from middle
or Offset from last
from Ending
column.
Port  Supported Data Types 

Input 

Output 

Reshape  Simulink 
Selector  Simulink 
Variable Selector  DSP System Toolbox 
reshape  MATLAB 
See Split Multichannel Signals into Several Multichannel Signals for related information.