﻿

Accelerating the pace of engineering and science

Identity Matrix

Generate matrix with ones on main diagonal and zeros elsewhere

Library

• Sources

dspsrcs4

• Math Functions / Matrices and Linear Algebra / Matrix Operations

dspmtrx3

Description

The Identity Matrix block generates a rectangular matrix with ones on the main diagonal and zeros elsewhere.

When you select the Inherit output port attributes from input port check box, the input port is enabled, and an M-by-N matrix input generates an M-by-N matrix output with the same sample period as the input. The values in the input matrix are ignored.

`y = eye([M N])						% Equivalent MATLAB code `

When you do not select the Inherit output port attributes from input port check box, the input port is disabled, and the dimensions of the output matrix are determined by the Matrix size parameter. A scalar value, M, specifies an M-by-M identity matrix, while a two-element vector, [M N], specifies an M-by-N unit-diagonal matrix. You can specify the output sample period using the Sample time parameter.

Examples

Set Matrix size to [3 6] to generate the 3-by-6 unit-diagonal matrix below.

$\left[\begin{array}{llllll}1\hfill & 0\hfill & 0\hfill & 0\hfill & 0\hfill & 0\hfill \\ 0\hfill & 1\hfill & 0\hfill & 0\hfill & 0\hfill & 0\hfill \\ 0\hfill & 0\hfill & 1\hfill & 0\hfill & 0\hfill & 0\hfill \end{array}\right]$

Dialog Box

The Main pane of the Identity Matrix block dialog appears as follows.

Inherit output port attributes from input port

Enables the input port when selected. In this mode, the output inherits its dimensions, sample period, and data type from the input. The output is always real.

Matrix size

The number of rows and columns in the output matrix: a scalar M for a square M-by-M output, or a vector [M N] for an M-by-N output. This parameter is disabled when you select Inherit input port attributes from input port.

Sample time

The discrete sample period of the output. This parameter is disabled when you select Inherit input port attributes from input port.

The Data Types pane of the Identity Matrix block dialog appears as follows.

Output data type

Specify the output data type for this block. You can select one of the following:

• A rule that inherits a data type, for example, Inherit: Inherit via back propagation. When you select this option, the output data type and scaling matches that of the next downstream block.

• A built in data type, such as double

• An expression that evaluates to a valid data type, for example, fixdt(1,16)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Output data type parameter.

Supported Data Types

PortSupported Data Types

Input

• Double-precision floating point

• Single-precision floating point

• Fixed point

• Boolean

• 8-, 16-, and 32-bit signed integers

• 8-, 16-, and 32-bit unsigned integers

Output

• Double-precision floating point

• Single-precision floating point

• Fixed point

• Boolean

• 8-, 16-, and 32-bit signed integers

• 8-, 16-, and 32-bit unsigned integers