Hello there :)
I have just started working with data dictionaries as I am currently building my first larger Simulink model. My first thought was to create a struct with different parameter objects for different submodels in order to get a structured division of my dictionary and not run the risk of losing the overview.
Unfortunately, I then realised that many object types such as Simulink.LookupTable objects within a struct in the data dictionary are not recognised in Simulink.
Here is an example code:
ModelDictObj = Simulink.data.dictionary.open('ModelDict.sldd');
dDataSectObj = getSection(ModelDictObj, 'Design Data');
lut = Simulink.LookupTable;
lut.Table.Value = someValues;
lut.Breakpoints(1).Value = someBreakpoints;
someStruct = struct();
someStruct.lut = lut;
addEntry(dDataSectObj, 'someStruct', someStruct);
saveChanges(ModelDictObj);
ModelDictObj.close();
Like this, the Lookup Table Block can not access the LookupTable object inside the dictionary in the Simulink model (using this code inside the lut-Block: someStruct.lut). It can only do this if the lut has been stored in the dictionary without the nesting in a struct.
My question now is whether there is a best practice solution to store different object types, including LookupTables, SimulinkParameters, MatlabValues and in the best case also SimulinkSignals within a dictionary in such a way that you get a hierarchical overview that fits my model hierarchy (a ‘folder’ for each subsystem for example).
I also have similar problems when accessing data dictionary data within a Stateflow model. The nesting of the files in structs does not seem to work there either. Currently I use ‘data store memory’ blocks for the necessary constants or signals. As a result, I have the problem that I can change values at different points in my model. Is this necessary or is there a way to directly access the values stored in the data dictionary within stateflow?
I would be very grateful if someone could give me some advice on best practice.
Many thanks in advance and best regards,
Danus Rawert