Overwrite submatrix or subdiagonal of input
Math Functions / Matrices and Linear Algebra / Matrix Operations
dspmtrx3
Signal Management / Indexing
dspindex
The Overwrite Values block overwrites a contiguous submatrix or subdiagonal of an input matrix. You can provide the overwriting values by typing them in a block parameter, or through an additional input port, which is useful for providing overwriting values that change at each time step.
The block accepts scalars, vectors and matrices. The output always has the same size as the original input signal, not necessarily the same size as the signal containing the overwriting values. The input(s) and output of this block must have the same data type.
The Source of overwriting value(s) parameter determines how you must provide the overwriting values, and has the following settings.
Specify via dialog
—
You must provide the overwriting value(s) in the Overwrite
with parameter. The block uses the same overwriting values
to overwrite the specified portion of the input at each time step.
To learn how to specify valid overwriting values, see Valid Overwriting Values.
Second input port
—
You must provide overwriting values through a second block input port, V
.
Use this setting to provide different overwriting values at each time
step. The output inherits its size and rate from the input signal, not the
overwriting values.
The rate at which you provide the overwriting values through
input port V
must match the rate at which the block
receives each input matrix at input port A
. In
other words, the input signals must have the same Simulink^{®} sample
time.
The overwriting values can be a single constant, vector, or matrix, depending on the portion of the input you are overwriting, regardless of whether you provide the overwriting values through an input port or by providing them in the Overwrite with parameter.
Valid Overwriting Values
Portion of Input to Overwrite  Valid Overwriting Values  Example 

A single element in the input  Any constant value, v  v 
A lengthk portion of the diagonal  Any lengthk column or row vector, v  $$k=3\text{}v=\left[\begin{array}{ccc}2& 4& 6\end{array}\right]\text{or}\left[\begin{array}{c}2\\ 4\\ 6\end{array}\right]$$ 
A lengthk portion of a row  Any lengthk row vector, v  $$k=3\text{}v=\left[\begin{array}{ccc}2& 4& 6\end{array}\right]$$ 
A lengthk portion of a column  Any lengthk column vector, v  $$k=2\text{}v=\left[\begin{array}{c}4\\ 6\end{array}\right]$$ 
An mbyn submatrix  Any mbyn matrix, v  $$\begin{array}{c}m=2\\ n=3\end{array}\text{}v=\left[\begin{array}{lll}4\hfill & 5\hfill & 6\hfill \\ 7\hfill & 8\hfill & 9\hfill \end{array}\right]$$ 
This block supports Simulink virtual buses.
Only some of the following parameters are visible in the dialog box at any one time.
Determines whether to overwrite a specified submatrix or a specified portion of the diagonal.
Determines where you must provide the overwriting values: either through an input port, or by providing them in the Overwrite with parameter. For more information, see Specifying the Overwriting Values.
The value(s) with which to overwrite the specified portion of
the input matrix. Enabled only when Source of overwriting
value(s) is set to Specify via dialog
.
To learn how to specify valid overwriting values, see Valid Overwriting Values.
The range of input rows to be overwritten. Options are All
rows
, One row
, or Range
of rows
. For descriptions of these options, see Parameters.
The input row that is the first row of the submatrix that the
block overwrites. For a description of the options for the Row and Starting
row parameters, see Settings for Row, Column, Starting Row, and Starting Column Parameters. Row is
enabled when Row span is set to One
row
, and Starting row when Row
span is set to Range of rows
.
Index of the input row that is the first row of the submatrix
that the block overwrites. See how to use these parameters in Settings for Row, Column, Starting Row, and Starting Column Parameters. Row
index is enabled when Row is set to Index
,
and Starting row index when Starting
row is set to Index
.
The offset of the input row that is the first row of the submatrix
that the block overwrites. See how to use these parameters in Settings for Row, Column, Starting Row, and Starting Column Parameters. Row
offset is enabled when Row is set
to Offset from middle
or Offset
from last
, and Starting row offset is
enabled when Starting row is set to Offset
from middle
or Offset from last
.
The input row that is the last row of the submatrix that the
block overwrites. For a description of this parameter's options, see Settings for Ending Row and Ending Column Parameters. This
parameter is enabled when Row span is set to Range
of rows
, and Starting row is set
to any option but Last
.
Index of the input row that is the last row of the submatrix
that the block overwrites. See how to use this parameter in Settings for Ending Row and Ending Column Parameters. Enabled
when Ending row is set to Index
.
The offset of the input row that is the last row of the submatrix
that the block overwrites. See how to use this parameter in Settings for Ending Row and Ending Column Parameters. Enabled
when Ending row is set to Offset
from middle
or Offset from last
.
The range of input columns to be overwritten. Options are All
columns
, One column
, or Range
of columns
. For descriptions of the analogous row options,
see Parameters.
The input column that is the first column of the submatrix that
the block overwrites. For a description of the options for the Column and Starting
column parameters, see Settings for Row, Column, Starting Row, and Starting Column Parameters. Column is
enabled when Column span is set to One
column
, and Starting column when Column
span is set to Range of columns
.
Index of the input column that is the first column of the submatrix
that the block overwrites. See how to use these parameters in Settings for Row, Column, Starting Row, and Starting Column Parameters. Column
index is enabled when Column is set
to Index
, and Starting column
index when Starting column is set
to Index
.
The offset of the input column that is the first column of the
submatrix that the block overwrites. See how to use these parameters
in Settings for Row, Column, Starting Row, and Starting Column Parameters. Column
offset is enabled when Column is set
to Offset from middle
or Offset
from last
, and Starting column offset is
enabled when Starting column is set to Offset
from middle
or Offset from last
.
The input column that is the last column of the submatrix that
the block overwrites. For a description of this parameter's options,
see Settings for Ending Row and Ending Column Parameters. This
parameter is enabled when Column span is set
to Range of columns
, and Starting
column is set to any option but Last
.
Index of the input column that is the last column of the submatrix
that the block overwrites. See how to use this parameter in Settings for Ending Row and Ending Column Parameters. This
parameter is enabled when Ending column is set
to Index
.
The offset of the input column that is the last column of the
submatrix that the block overwrites. See how to use this parameter
in Settings for Ending Row and Ending Column Parameters. This
parameter is enabled when Ending column is set
to Offset from middle
or Offset
from last
.
The range of diagonal elements to be overwritten. Options are All
elements
, One element
, or Range
of elements
. For descriptions of these options, see Overwriting a Subdiagonal.
The input diagonal element that is the first element in the
subdiagonal that the block overwrites. For a description of the options
for the Element and Starting element parameters,
see Element and Starting Element Parameters. Element is
enabled when Element span is set to One
element
, and Starting element when Element
span is set to Range of elements
.
Index of the input diagonal element that is the first element
of the subdiagonal that the block overwrites. See how to use these
parameters in Element and Starting Element Parameters. Element
index is enabled when Element is set
to Index
, and Starting element
index when Starting element is set
to Index
.
The offset of the input diagonal element that is the first element
of the subdiagonal that the block overwrites. See how to use these
parameters in Element and Starting Element Parameters. Element offset is
enabled when Element is set to Offset
from middle
or Offset from last
,
and Starting element offset is
enabled when Starting element is set to Offset
from middle
or Offset from last
.
The input diagonal element that is the last element of the subdiagonal
that the block overwrites. For a description of this parameter's options,
see Ending Element Parameters.
This parameter is enabled when Element span is
set to Range of elements
, and Starting
element is set to any option but Last
.
Index of the input diagonal element that is the last element
of the subdiagonal that the block overwrites. See how to use this
parameter in Ending Element Parameters.
This parameter is enabled when Ending element is
set to Index
.
The offset of the input diagonal element that is the last element
of the subdiagonal that the block overwrites. See how to use this
parameter in Ending Element Parameters.
This parameter is enabled when Ending element is
set to Offset from middle
or Offset
from last
.
To overwrite a submatrix, follow these steps:
Set the Overwrite parameter
to Submatrix
.
Specify the overwriting values as described in Specifying the Overwriting Values.
Specify which rows and columns of the input matrix are contained in the submatrix that you want to overwrite by setting the Row span parameter to one of the following options and the Column span to the analogous columnrelated options:
All rows
— The submatrix
contains all rows of the input matrix.
One row
— The submatrix
contains only one row of the input matrix, which you must specify
in the Row parameter, as described in the following
table.
Range of rows
—
The submatrix contains one or more rows of the input, which you must
specify in the Starting Row and Ending
row parameters, as described in the following tables.
When you set Row span to One
row
or Range of rows
, you
need to further specify the row(s) contained in the submatrix by setting
the Row or Starting row and Ending
row parameters. Likewise, when you set Column
span to One column
or Range
of columns
, you must further specify the column(s) contained
in the submatrix by setting the Column or Starting
column and Ending column parameters.
For descriptions of the settings for these parameters, see the following
tables.
Settings for Row, Column, Starting Row, and Starting Column Parameters
Settings for Specifying the Submatrix's First Row or Column  First Row of Submatrix (Only row for Row span = One row)  First Column of Submatrix (Only row for Row span = One row) 

 First row of the input  First column of the input 
 Input row specified in the Row index parameter  Input column specified in the Column index parameter 
 Input row with the index  Input column with the index 
 Last row of the input  Last column of the input 
 Input row with the index  Input column with the index 
 Input row with the index  Input columns with the index 
Settings for Ending Row and Ending Column Parameters
Settings for Specifying the Submatrix's Last Row or Column  Last Row of Submatrix  Last Column of Submatrix 

 Input row specified in the Ending row index parameter  Input column specified in the Ending column index parameter 
 Input row with the index  Input column with the index 
 Last row of the input  Last column of the input 
 Input row with the index  Input column with the index 
 Input row with the index  Input columns with the index 
For example, to overwrite the lowerright 2by3 submatrix of a 3by5 input matrix with all zeros, enter the following set of parameters:
Overwrite = Submatrix
Source of overwriting value(s) = Specify
via dialog
Overwrite with = 0
Row span = Range
of rows
Starting row = Index
Starting row index = 2
Ending row = Last
Column span = Range
of columns
Starting column = Offset
from last
Starting column offset = 2
Ending column = Last
The following figure shows the block with the above settings overwriting a portion of a 3by5 input matrix.
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
Ending column = Index
Ending column index = 5
To overwrite a subdiagonal, follow these steps:
Set the Overwrite parameter
to Diagonal
.
Specify the overwriting values as described in Specifying the Overwriting Values.
Specify the subdiagonal that you want to overwrite by setting the Diagonal span parameter to one of the following options:
All elements
— Overwrite
the entire input diagonal.
One element
— Overwrite
one element in the diagonal, which you must specify in the Element parameter
(described below).
Range of elements
—
Overwrite a portion of the input diagonal, which you must specify
in the Starting element and Ending
element parameters, as described in the following table.
When you set Diagonal span to One
element
or Range of elements
,
you need to further specify which diagonal element(s) to overwrite
by setting the Element or Starting
element and Ending element parameters.
See the following tables.
Element and Starting Element Parameters
Settings for Element and Starting Element Parameters  First Element in Subdiagonal (Only element when Diagonal span = One element) 

 Diagonal element in first row of the input 
 kth diagonal element, where k is the value of the Element index or Starting element index parameter 
 Diagonal element in the row with the index 
 Diagonal element in the last row of the input 
 Diagonal element in the input row with the index 
 Diagonal element in the input row with the index 
Ending Element Parameters
Settings for Ending Element Parameter  Last Element in Subdiagonal 

 kth diagonal element, where k is the value of the Ending element index parameter 
 Diagonal element in the row with the index 
 Diagonal element in the last row of the input 
 Diagonal element in the input row with the index 
 Diagonal element in the input row with the index 
The input(s) and output of this block must have the same data type.
Port  Supported Data Types 

A 

V 

B 

Reshape  Simulink 
Selector  Simulink 
Submatrix  DSP System Toolbox 
Variable Selector  DSP System Toolbox 
reshape  MATLAB 