simulink coder, initialize Simulink.Bus top level input ports
Afficher commentaires plus anciens
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.
Réponses (2)
Kaustubha Govind
le 29 Avr 2013
0 votes
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 commentaires
Roman Luz
le 29 Avr 2013
Kaustubha Govind
le 30 Avr 2013
Ah ok. I'm not sure how else you can achieve what you need. Could you try contacting MathWorks Technical Support about this?
Roman Luz
le 29 Avr 2013
0 votes
Catégories
En savoir plus sur Simulink Coder dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!