How to initialise values for nested bus signals with different datatypes, when I use a data store memory block to store the bus signals?
1 view (last 30 days)
Show older comments
How can I initialize the values of signals in a bus, if I have a nested bus signal (one bus signal that comprises of another two bus signals)? Additionally, these bus signals contain different types of data (some are structures, some are matrices). These signals are all stored in a Data Store Memory Block.
Accepted Answer
MathWorks Support Team
on 8 Nov 2011
One would have to create a structure with elements containing initial values desired and provide that as the Initial value to the Data Store memory block.
Attached documents illustrate an example where bus ‘S’ has two nested buses ‘a’ and ‘a1’ of types ‘subbus1’ and ‘subbus2’ respectively. ‘subbus1’ has two elements which take in doubles while ‘subbus2’ has one element that takes in a matrix of size 2x2.These were created using the Bus Editor.
The Structure ‘Init’ which contains all the initial values, comprises of two structures ‘a’ and ‘a1’ - corresponding to the 2 nested buses 'a' and 'a1'. Structure ‘a’ has two elements ‘a’ and ‘b’ with values 1 and 2 respectively. Structure ‘a1’ has an element ‘c’ which is a matrix. All these variables are in the MAT file ‘test.mat’ which is loaded into the workspace in the Init callback of the model. The initial values are given to the signals by placing the structure ‘Init1’ in the 'Initial Value' option of the Data Store memory block. Execute the model and observe that the values specified in the Init structure are written onto the signals.
0 Comments
More Answers (0)
See Also
Categories
Find more on Sources 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!