Data Dictionary and Model Parametrization

조회 수: 35 (최근 30일)
Florian
Florian 2015년 2월 27일
댓글: Tom Baker 2021년 4월 21일
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.

채택된 답변

Sebastian Castro
Sebastian Castro 2015년 3월 4일
편집: Sebastian Castro 2015년 3월 4일
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
  댓글 수: 1
Tom Baker
Tom Baker 2021년 4월 21일
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

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Wei
Wei 2017년 12월 24일
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?

카테고리

Help CenterFile Exchange에서 System Composer에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by