simulink coder, initialize Simulink.Bus top level input ports
6 次查看(过去 30 天)
显示 更早的评论
I have a simulink model that I am autocoding to C++ (via Simulink coder). The subsystem I want to build has inputs and outputs that are buses. So I defined Simulink.Bus data types for the autocode to treat the buses as C structs. Unfortunately, my input bus gets inizialized to a const struct where all the values are 0. This results in division by 0 and NaNs quickly propagate everywhere.
Is it possible to define an initial value of an input port to replace the default zeros?
In my full simulink model there are no top level inputs or outputs -- the initial values are specified at the integrators and unit delays which are all connected in a loop. I've broken my model into atomic subsystems and I'm builing the subsystems independently. So the autocoded algorithm starts at the input port rather than a block that has an initial state.
0 个评论
回答(2 个)
Kaustubha Govind
2013-4-29
I haven't tried this, but I wonder if you could use Simulink.Signal objects to specify initial values for your signal. Right-click on the signal exiting the Inport block and select Properties in the context menu. Enter the signal name as the name of a Simulink.Signal object (DataType set to your Simulink.Bus type and the appropriate InitialValue) in the base workspace, and check the box "Signal name must resolve to Simulink signal object".
2 个评论
Kaustubha Govind
2013-4-30
Ah ok. I'm not sure how else you can achieve what you need. Could you try contacting MathWorks Technical Support about this?
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!