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

41 visualizaciones (últimos 30 días)
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 comentario
Sebastian Wendel
Sebastian Wendel el 8 de Sept. de 2020
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.

Iniciar sesión para comentar.

Respuestas (2)

Sebastian Wendel
Sebastian Wendel el 11 de Sept. de 2020
Editada: Sebastian Wendel el 11 de Sept. de 2020
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 el 11 de Sept. de 2020
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 comentario
laiche zeghdi
laiche zeghdi el 19 de Sept. de 2023
i have almost same problem how can fixed this (Inferred size ('scalar') for data (#28) does not match back propagated size ('Sa') from Simulink

Iniciar sesión para comentar.

Categorías

Más información sobre Event Functions en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by