Data Dictionary and Model Parametrization

30 Ansichten (letzte 30 Tage)
Florian
Florian am 27 Feb. 2015
Beantwortet: Josh Kahn am 25 Jun. 2024
I am working on a large simulation model under Matlab/Simulink. I am investigating the ability to do the Simulink model parametrization via data dictionaries (DD). The main purpose of the Simulink model is Monte Carlo investigations of certain parameters.
In this context the following questions arose:
1. DD and base workspace:
a.) A Simulink model “a.slx“ is linked to a DD “a.sldd“. Does this Simulink model „search“ their model parameters/bus objects/configuration parameters ONLY in the DD or can parameters be defined in the base workspace in parallel? That means: is it mandatory that all model parameters/bus objects/configuration parameters are defined in “a.sldd”?
b.) I assume the simulink model takes ONLY the parameters from the corresponding DD (here “a.sldd”). In this case it should be possible to have the same parameters in the base workspace and in the DD without any influence or corruption. I did this but I got the error message:
The symbol 'cfg_1' has more than one Definition
  • 'cfg_1' is defined in data dictionary 'aerodynamic.sldd'
  • 'cfg_1' is defined in the base Workspace
So my question: it is apparently not possible to have a “hybrid” parameter concept, which means it is not possible parametrize the model via base workspace AND DD variables?
2. Simulink model “a.slx” is linked with DD “a.sldd”. Simulink model “b.slx” is linked with DD “b.sldd”. Both models are referenced (via model referencing) in a parent model on the upperst model hierarchy. The output of model “a.sldd” constitutes the input of model “b.sldd” and is a bus (“a_bus”) defined via a bus object “a_bus_obj” in “a.sldd”. Since the bus is entering model “b.sldd” is it mandatory to define the bus object also in the DD “b.sldd”?
3. We assume the same architecture as in 2. In both models “a.slx” and “b.slx” exists a parameter “mass“. In both models the variable “mass” has a different value. Since both models are on the same top level of the parent model, I would assume that this wouldn’t result in an error. But Simulink throws an error stating that it is not possible. So, my question: is it in general not possible to use the same variable in two DD with different values?
Please contact me if you have further questions. Thanks a lot for all your help.

Akzeptierte Antwort

Sebastian Castro
Sebastian Castro am 4 Mär. 2015
Bearbeitet: Sebastian Castro am 4 Mär. 2015
Hi Florian,
I'll give these questions a try.
1. The Data Dictionary is intended to completely replace the base workspace. For all intents and purposes, a Data Dictionary acts like the base workspace, but with the extra security level that prevents you from accidentally clearing or overriding parameters with other things you're working on.
The only exception/weird rule I've found is when your model configuration parameters require external input (in the Data Import/Export pane). In this situation, the base workspace seems to be still used. This facilitates injection of external inputs using MATLAB scripts.
2/3. Yes, you need to make sure the same variable is used in both dictionaries. It isn't sufficient to create the same variable in 2 separate dictionaries even if their values are exactly the same. This is a protection mechanism which prevents accidentally changing one variable definition, but not the other one. It's a best practice to single-source your code/data/etc., anyhow.
In general, you should take advantage of Data Dictionary referencing as much as possible. For example, you can have a dictionary "a.sldd" which contains data exclusively used by "a.slx". Similarly, you have a dictionary "b.sldd" which contains data exclusively used by "b.slx". If you have common data between the models (like your Bus object), create a "commonData.sldd" dictionary and reference it in both "a.sldd" and "b.sldd".
Also, if you actually want to have 2 parameters named "mass" that take on different values, you can still do this across models by using their respective model workspaces . This is where you are allowed to do that kind of thing.
Hope that helps.
- Sebastian
  2 Kommentare
Tom Baker
Tom Baker am 21 Apr. 2021
Hi Sebastian,
Does that mean it is not possible to use the same variable "mass" with two differently defined values in the two data dictionaries and different reference models?
The solution would be to define a variable "mass_a" in "a.sldd" and "mass_b" in "b.sldd"?
Thanks!
Tom
Josh Kahn
Josh Kahn am 25 Jun. 2024
Bearbeitet: Josh Kahn am 25 Jun. 2024
Yes Tom, that is correct. If one of the dictionaries references the other, the variable names must be unique. If the dictionaries are not referenced, they can have the same name, even if one model references the other, but this can also lead to confusion.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Wei
Wei am 24 Dez. 2017
No sldd & baseworkspace mix is too restrictive - a model linked to sldd cannot use 'From Workspace', a common approach importing field collected data. Not all import can be done using root level inport.
Maybe there is alternative?

Josh Kahn
Josh Kahn am 25 Jun. 2024
For anyone looking for more information on dictionary referencing/managing shared data between models, I have another write-up here that may be of help:

Kategorien

Mehr zu System Composer finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by