Main Content

Create Diagonal Matrix

Create square diagonal matrix from diagonal elements

  • Library:
  • DSP System Toolbox / Math Functions / Matrices and Linear Algebra / Matrix Operations

  • Create Diagonal Matrix block

Description

The Create Diagonal Matrix block populates the diagonal of the M-by-M matrix output with the elements contained in the length-M vector input D. The elements off the diagonal are zero.

A = diag(D)		% Equivalent MATLAB code 

Ports

Input

expand all

Input to convert into a diagonal matrix, specified as an M-element vector.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point
Complex Number Support: Yes

Output

expand all

Output specified as an M-by-M matrix, where M is the length of the input vector.

The output is equivalent to:

A = diag(D)		% Equivalent MATLAB code 

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point
Complex Number Support: Yes

Block Characteristics

Data Types

Boolean | double | fixed point | integer | single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

See Also

Blocks

Functions

Introduced before R2006a