Create Diagonal Matrix
R2026bCreate square diagonal matrix from diagonal elements
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
Ports
Input
Output
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Programmatic Use: Add Block
To add the block programmatically, use the add_block function with one of these library block paths as the source.
"simulink/Matrix Operations/Create Diagonal Matrix"
Example: add_block("simulink/Matrix Operations/Create Diagonal Matrix","myModel/myBlock",MakeNameUnique="on")
