Main Content

Create Diagonal Matrix

Create square diagonal matrix from diagonal elements

  • Create Diagonal Matrix block

Libraries:
Simulink / Matrix Operations

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.

Equivalent MATLAB® code is given by:

A = diag(D)

Examples

expand all

This example shows how to use the Create Diagonal Matrix block.

Open the Simulink model.

The Create Diagonal Matrix block creates a diagonal matrix from the input values. The output matrix in the model has the input vector as its diagonal.

Run the model to verify the output.

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™.

Version History

Introduced before R2006a

expand all

See Also

Blocks

Functions