Inferred size ('[1 20]') for data 'MyMatrix_ToVector' does not match back propagated size ('[20]') from Simulink.

41 ビュー (過去 30 日間)
Sebastian Wendel
Sebastian Wendel 2020 年 9 月 8 日
コメント済み: laiche zeghdi 2023 年 9 月 19 日
Hello,
when using Simulink with a Matlab-Function I have the issue that the dimensions do not match, [1 20] vs [20]. How can I convert to a [20] array? I cannot modify the block that expects the [20] array because it is a compiled function.
Code:
lengthOf_MyMatrix = numel(MyMatrix); % evaluate the targets size, it's a 4*5 Matrix
MyMatrix_ToVector = reshape(MyMatrix,1,lengthOf_MyMatrix); % Try to shape it to a Vector
Error-Message: Inferred size ('[1 20]') for data 'MyMatrix_ToVector' does not match back propagated size ('[20]') from Simulink.
Thank you very much,
Best Regards, Sebastian Wendel
  1 件のコメント
Sebastian Wendel
Sebastian Wendel 2020 年 9 月 8 日
P.S. I had some tries to fix it, now I get:
Error-Message: Failed to resolve data 'MyMatrix_ToVector' in 'MySimulinkFunction/MATLAB Function' to a valid Simulink.Signal object.

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

回答 (2 件)

Sebastian Wendel
Sebastian Wendel 2020 年 9 月 11 日
編集済み: Sebastian Wendel 2020 年 9 月 11 日
Dear Uday,
thank you very much, sorry for the late reply. The Matlab-Block is actually connected to a dSpace Flash Block which is a [20] Array.
I was able to fix it yesterday with the following code and setting:
Code:
lengthOf_MyMatrix = numel(MyMatrix); % evaluate the targets size, it's a 4*5 Matrix
MyMatrix_ToVector = reshape(MyMatrix,1,lengthOf_MyMatrix)'; % Try to shape it to a Vector
Ports and Data Manager:
Best Regards, Sebastian Wendel
P.S. Sorry that I had to change the variable-names, not to publish details officially. This is the Simulink-Section:

Uday Pradhan
Uday Pradhan 2020 年 9 月 11 日
Hi Sebastian,
You can try editing the size of the output of your MATLAB function. To do this, follow these steps:
  1. Open the MATLAB function in the MATLAB editor.
  2. Now click on the "EDITOR" tab if you are already not on that tab.
  3. Search for "Edit data" option in the pane. It should be next to the "Build Model" option.
4.A new window called "Ports and Data Manager" should open up.
5. Select the output in the left pane and edit the Size to [1 20] instead of -1
Apply the settings and run the model again. I hope this resolves the issue.
  1 件のコメント
laiche zeghdi
laiche zeghdi 2023 年 9 月 19 日
i have almost same problem how can fixed this (Inferred size ('scalar') for data (#28) does not match back propagated size ('Sa') from Simulink

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

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by