During the life of a model, you will very likely need to change many configuration parameters to complete different tasks. For example, when debugging you want to enable many run time diagnostics to catch modeling errors. When the model is well tuned and you want to use it for a Monte-Carlo study, you want to disable any diagnostic that may affect performance.
These collections of configuration parameters can be stored as Configuration Sets.
Multiple Configuration Sets in One Model
Do you know it is possible to store more than one configuration in a model?
An easy way to create a second configuration is from the Model Explorer. Right-click on the configuration and select Copy:
Right-click on the model and select Paste:
Now that you have two configurations in the model, select the one to be used by right-clicking on it and selecting Activate:
Storing a Configuration Set in a File
When I create a new model, I usually change the configuration for 2 or 3 of my typical use cases:
- Physical Modeling: For models using Simscape I use a configuration with the ode23t solver and the Simscape Logging enabled.
- Code generation: For models that generate code I use a Fixed-Step Discrete solver, ert.tlc target, and I enable the code generation report.
- Debugging: When debuging, I disable most optimizations, and set many diagnostics to error.
To quickly configure a new model for those tasks, what I did is that I exported the configurations I use most often to MATLAB files:
In the example below, the exported MATLAB file, configCG, is a function that creates a configuration set object. When I create a new model, I can easily attach and activate my previously saved configurations using attachConfigSet and setActiveConfigSet:
Now it's your turn
Do you take advantage of all those ways to manage configuration sets? Let us know by leaving a comment here.
要发表评论，请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。