Create diagonal matrix from vector in Simulink without DSP toolbox and without knowing the dimension of the vector

1 view (last 30 days)
Hey!
I need to convert a vector signal into a diagonal matrix in Simulink. The problem is that I do not have the DSP toolbox so I cannot use the corresponding block that exists. Also, I do not know the dimension of the signal therefore I cannot use a constant block with "eye(<dimension>)" to create the diagonal matrix with the help of the identity matrix.
Do you have any idea to accomplish this?
Thanks!
Cedric

Answers (1)

Paul
Paul on 16 Jan 2022
The easiest way, perhaps not without drawbacks, is to use an Interpreted Matlab Function block. In the dialog box make the 'Matlab function' diag, and make sure the box for 'Collapse 2-D results to 1-D' is not checked.

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!