repmat function in Simulink

39 ビュー (過去 30 日間)
Rubem Pacelli
Rubem Pacelli 2020 年 8 月 16 日
編集済み: Ivan Garcia 2021 年 7 月 30 日
I would like to perform the repmat() function in Simulink. Apparently, there isn't a block for this purpose. So I doing this using the MATLAB function block. Here the following signal dimensions that I'm trying to handle
The code is just:
function y = repmat(u, Ns)
y = repmat(u, [Ns,1,1]); % Ns is a paramater of my system
It works, but using this block is always awkward and inefficient. Is there a clever way to do this?
  15 件のコメント
Rubem Pacelli
Rubem Pacelli 2020 年 11 月 5 日
編集済み: Rubem Pacelli 2020 年 11 月 5 日
Thank you! I think you meant to say [1, 2, Ns] instead of [1, 2, Ns*2]. Before the reshape I have a [1x2*Ns] vector. Hence, it is not possible to reshape to [1, 2, Ns*2]. When I put [1, 2, Ns] in a reshape block, I got a matrix in a shape that I was looking for. :)
Walter Roberson
Walter Roberson 2020 年 11 月 5 日
Yes, you are right, [1, 2, Ns]

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

採用された回答

Ivan Garcia
Ivan Garcia 2021 年 7 月 30 日
編集済み: Ivan Garcia 2021 年 7 月 30 日
You can model the repmat function used in the MATLAB function block above in Simulink as follows:
If the input array "u" has 2 dimensions feed it into a "Reshape" block. Set the output dimensionality to "Customize" and then set the output dimensions to: [1, XSize, YSize], where XSize and YSize are the dimension sizes of the original array. This will expand the third dimension. Then feed the output of the reshape block into a "Selector" block. Set the number of input dimensions to 3. Then for the first dimension set the index option to "Index vector (dialog)" and set the index value to "ones(1, Ns)". For the other two dimensions set the index option to "Select all".
Hope this helps.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by