How to initialize Simulink Data Store Memories with Real Time Windows Target
12 views (last 30 days)
Show older comments
Hi!
I use Data Store Memories through various subsystems of my Simulink Model. I use the Data Store Memory Block in the model root level. In the field "Initial Value" of this block I entered a workspace variable "InitVal". If I compile (built) the Model for Real Time Windows Target, the value of InitVal is used as initial value of the Data Store.
And here is the problem: If I now change the value of the workspace variable InitVal (for example from a m-file), then connect to the target and start the simulation (both from a m-file), the initial value of the Data Store Memory is not updated. It stays at the value that InitVal had, when the model was built.
Is there any possibility to init a Data Store Memory in a compiled Simulink Model from a m-file? Without re-building.
Thank you very much for your answers! Arne
2 Comments
Answers (2)
Jan Houska
on 7 Feb 2013
You are correct that this does not work and it should. I'm filing a bug record for this.
To work around the problem, you can use Data Store Write together with an enabled subsystem. First, connect a Data Store Write block with constant with the value of InitVal. Then put these two blocks into an enabled subsystem. And, connect the enable port of the subsystem to an output of Clock compared with zero. This way, the Data Store is initialized by InitVal at simulation start and not affected later. If you are interested in an example model, please send me an e-mail.
2 Comments
Jan Houska
on 8 Feb 2013
I don't know about any possibility to write Data Store in compiled code using MATLAB code. Only parameters can be changed from MATLAB code, but the immediate value is not a parameter. The initial value is a parameter, but it is too late to change it after the model is loaded and initailized.
Currently, I think there is no workaround other than already presented above.
See Also
Categories
Find more on Introduction to Installation and Licensing 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!