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

조회 수: 8 (최근 30일)
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 CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by