Transpose Matrix in Simulink 2020a

16 ビュー (過去 30 日間)
Richard
Richard 2025 年 11 月 25 日 20:32
コメント済み: Walter Roberson 2025 年 11 月 25 日 22:30
I need to transpose a matrix to [1x20] from [20x1] in Simulink 2020a. The transpose block was added in a later release so I cannot use that block. I am thinking of adding "Matlab Function Block" and having that transpose the matrix, but I need to do this through a script.
  3 件のコメント
Richard
Richard 2025 年 11 月 25 日 21:25
The function block is being created via a callback when the user determines the model interface needs to be updated. After the callback finishes, the interface is locked and not modified until the user manually fires it again. This is used only for modeling purposes only.
The whole thing is scripted since the amount of signals in the interface is around 2 thousands. I don't free comfortable asking someone to manual build the interface up.
Walter Roberson
Walter Roberson 2025 年 11 月 25 日 22:30
If you are generating code, then it costs next to nothing to generate a function header on it. The only extra overhead is that you need to be sure to "clear" the function by name after generating the new function, so that the Execution Engine will know to get rid of the tokenized version of the old file.

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2025 年 11 月 25 日 21:00
If it must be done through a script, then use an Interpreted Function Block https://www.mathworks.com/help/simulink/slref/interpretedmatlabfunction.html and set the MATLAB Function parameter to transpose or ctranspose (depending on your purposes.)
Note that this will be relatively slow, and is not recommended. Interpreted MATLAB Function blocks will be removed at some later release.

Paul
Paul 2025 年 11 月 25 日 21:49
The online doc doesn't go back as far as 2020a, but in 2021a one would use the Math Function block. I'm sure (well, nearly sure) that the same functionality is offered in 2020a.

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by