Borrar filtros
Borrar filtros

Array size from Stateflow is different after simulation is complete after sending to workspace.

5 visualizaciones (últimos 30 días)
I'm generating a signal that is output from a Stateflow chart in Simulink R2016a. The size of the variable that is ultimately output in Stateflow is a 6 x 5 array. However, when I send it to the base workspace using the To Workspace Simulink block, I get a much larger array once the simulation is complete. Specifically, when I send it to a 2D array, it was instead a 91056 x 5 2D array mostly full of zeros.
Out of curiosity I changed it to output 2D arrays as 3D arrays and it was a 6 x 5 x 15176 array and only the last 2D array had non-zero columns.
This indicates to me I had made an oversight in my Stateflow chart and I'm too lazy to go through the work to debug and correct it. Instead, I would rather preserve the very last 2D array since I will need only that for later calculations later during the simulation (although right now I am only interested in this first half). Is there an easy way to preserve only the last array using Simulink blocks once the first half of the simulation is over so I can use that during the second half, or will I need to come up with a clever Matlab user-define function block?
Addendum I just tried to use a simpler Matlab function block that runs
x_out = x_in(x_in~=0);
and then I put the signal through a reshape block to make the 30 x 1 array a 6 x 5.
The error I get is
'x_out' is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify 'x_out' is defined in terms of non-tunable parameters, or select the 'Variable Size' check box and specify the upper bounds in the Size box.
I get this same error whether I just use Matlab block with or without the reshape.
I've had similar errors trying to debug my code, and I had set the size of the outputs. But I tried to do that here and the code wouldn't compile still.

Respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by