States Not Visible in Coder-Generated S-Function Blocks

1 Ansicht (letzte 30 Tage)
Greg
Greg am 4 Jun. 2013
I'm trying to use the Simulink coder to codegen a fairly complex model into an S-Function block in order to improve the performance of the model. I can do this, but when I do, all of the states in the model vanish and become inaccessible from outside the S-Funcion. When I call Simulink.BlockDiagram.getInitialState() on the model with the generated S-Function block, it returns an empty array.
I have previously been able to access states inside generated S-Function blocks which were created for less complex models, so I know it should be possible. The states are (for the moment) just a bunch of Unit Delay blocks located inside a (non-Atomic) Subsystem. There are Reference Models in the model, but there are currently not any states in the Reference Models.
I've dug around in some of the codegen'd C-code, and the "Subsystem_sf.c" file actually calls "ssSetNumDiscStates(S, 0);", explicitly setting the number of discrete states to zero. This is dispite the same function actually initializing all of the variables for the states, which are currently set to "ImportedExternPointer". (I have tried other settings of the Code Generation Storage Class, and it does not appear to make any difference).
Any idea why my states are disappearing on me?
  2 Kommentare
Greg
Greg am 4 Jun. 2013
A little bit more playing around with very simple models might suggest that this only happens when the subsystem being codegen'd contains a Reference Model. (Even if the states are not contained within that Reference Model).
Kaustubha Govind
Kaustubha Govind am 4 Jun. 2013
Greg: The fact that the behavior changes with the presence of referenced models seems suspicious to me. Perhaps you should report this to MathWorks Support?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by