simulink coder, initialize Simulink.Bus top level input ports
6 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Kaustubha Govind
on 29 Apr 2013
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 Comments
Kaustubha Govind
on 30 Apr 2013
Ah ok. I'm not sure how else you can achieve what you need. Could you try contacting MathWorks Technical Support about this?
See Also
Categories
Find more on Simulink Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!