Referencing Configuration Sets for Model Reference
A few weeks ago I described the possibility of储存更多的多个配置集在唱歌le model.
Today we will do the opposite:Sharing one configuration set among multiple models.
Reference Configuration Set
By default, in Simulink, the configuration of a model is stored in the model file itself.
However when you have a hierarchy of referenced models, those models must have similar configuration sets. Instead of having each model storing its own configuration, it is possible to have all models refer to a single configuration set.
To begin, setup the configuration you want in one model and convert it to a configuration reference:
A dialog will allow you to specify the name of the configuration set and give you the possibility to save it to a MAT-file or a MATLAB script.
Note that if you do not save the configuration set at this time, it is always possible to save it later usingSimulink.BlockDiagram.saveActiveConfigSet
Once the configuration object is in the base workspace, you can configure all your child models to refer to it:
Update:This can be done by right-clicking on the top model configuration reference and selectingPropagate to Referenced Models
That way if the configuration needs to change, you will need to make the change in only one place.
Creating Variants of a common configuration set
In a hierarchy of referenced models, it is common to want all the child models to have almost the same configuration, except a few parameters. For example, in the following model I want the three child models to have all the same configuration, except I wantchild3.slxto execute at a different sample time.
To make that happen, I stored a configuration namedmyConfigin a MATLAB scriptconfigFile.m. In an initialization script that I execute before running my model (for example themodel PreLoadFcn callback), I copy this configuration set and modify the parameter I need.
That way, I can configurechild3.slxto refer tomyConfigTS2. If, in the future, I need to change a parameter in all the child models, I only need to do it once inconfigFile.m. When my initialization script will createmyConfigTS2, it will automatically inherit this change.
Now it's your turn
Do you take advantage of configuration reference? Let us know by leaving acomment here
- Category:
- Model Reference,
- Model-Based Design
Comments
To leave a comment, please clickhereto sign in to your MathWorks Account or create a new one.