States Not Visible in Coder-Generated S-Function Blocks

1 次查看(过去 30 天)
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 个评论
Greg
Greg 2013-6-4
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 2013-6-4
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?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by