Guy on Simulink

Simulink & Model-Based Design

Parameter Values in Blocks Dialogs

MATLAB R2022b was released a few weeks ago, so it's time to highlight a few new Simulink features. In this post, I decided to focus on one feature that might pass a little bit under the radar, but that I believe can save you a lot of time.
In case you haven't noticed, in R2022b we now display the evaluated value of parameters in block dialogs:
The same also happens in the Property Inspector:
Here is a quick video illustrating that this feature immediately displays any expression you type in the block dialog, evaluated in the context of where the block is located:

A More Complex Example

Obviously, for simple models, figuring out the value of a parameter is relatively easy. You can simply type it in the base workspace or look inside a data dictionary. Let's look into a more complex setup where the utility of this feature becomes more obvious.
To illustrate how valuable this feature is in a more complex project, try using the Four Hydraulic Cylinder Simulation example included with Simulink.
If you look at the dialog of one of the Constant blocks in Cylinder 2, you can immediately see that the expression Ac^2/K resolves to 5e-11:
If you do the same inside Cylinder 3, the same expression resolves to a different value, 8e-11:
The reason is that those masked subsystems receive different parameters values. Without this feature, you would need to go through a series of steps to figure out those values without simulating the model:
  • Look at the Mask Editor to see which dialog parameter corresponds to Ac and K.
  • Look in the dialog of each masked Subsystem to see which parameter is passed to the mask dialog of each block
  • Look in the model workspace to find the actual value of those parameters
  • Evaluate the equation in the MATLAB base workspace to see the final values
That's a lot of clicks! Imagine now if you have multiple levels of nested masked Subsystems how this complexity grows.

Custom MATLAB Objects

If you define your model parameters using MATLAB classes as I described in the 5-post series on slPart, what the evaluated value will display is a hyperlink that opens the auto-generated class documentation, which then includes a hyperlink to open the source code. If you download my example on MATLAB File Exchange, or clone the repository on GitHub, you will see that this looks like the following:
If the MATLAB class is well-commented, accessing all this information with one click is very useful.

Disabling it

To take advantage of this feature, you have nothing to do, it's just there by default. If, for any reason, you would like to disable it, this can be done from Simulink Preferences.
If you end up disabling this feature, I would be very interested to hear the reason.

Now it's your turn

Let us know in the comments below what you think of this feature. I personally find that it is already saving me many clicks every day.
  • print


コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。