How to sum matrix of different size on Simulink? (R2019a)

4 ビュー (過去 30 日間)
Rubem Pacelli
Rubem Pacelli 2020 年 3 月 17 日
コメント済み: Carel 2022 年 9 月 29 日
I have this block in my system:
The expected behavior is to perform as it's done on Matlab.
However, I receive this error:
How can I solve this problem?
PS1: I know that it seems pretty stupid. But maybe I'm pretty stupid.
PS2: I searched. Really.

採用された回答

Rubem Pacelli
Rubem Pacelli 2020 年 4 月 20 日
編集済み: Rubem Pacelli 2020 年 8 月 9 日
I found out what is going on. It turns out that there is a specific block to sum a vector along a multidimensional matrix. These blocks are called:
Array-Vector add
Array-Vector subtract
Array-Vector multiply
Array-Vector divide
It can do any basic operations that I was looking for.
  1 件のコメント
Carel
Carel 2022 年 9 月 29 日
It should be noted that this requires the DSP Toolbox.
I imagine you would be able to use the simple math blocks if you can make them have the same size, but using repmat in matlab function block in simulink gives different results than using it in a .m so I haven't been able to figure out a way yet

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

その他の回答 (1 件)

BobH
BobH 2020 年 3 月 17 日
The dimensions must agree, in MATLAB.
Z = zeros(400,32);
O = ones(1,32);
Z+O;
Error using +
Matrix dimensions must agree.
O = ones(400,32);
r = Z+O;
size(r)
ans =
400 32
  4 件のコメント
Rubem Pacelli
Rubem Pacelli 2020 年 3 月 18 日
編集済み: Rubem Pacelli 2020 年 3 月 18 日
I'm using R2019a, on Linux (Mint). When I run your example, It works correctly. However, in Simulink it doesn't happen.
madhan ravi
madhan ravi 2020 年 3 月 18 日
BobH if you could see in each thread of the question there is a specific field named Release for the OPs to fill in the version they use.

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

カテゴリ

Help Center および File ExchangeArray and Matrix Mathematics についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by