Guy on Simulink

Simulink & Model-Based Design

Which callback should I use?

This week's post has been triggered by question recently posted on this blog regarding Masking and Variant Subsystems.

If you look at this exchange I had with Xiaojun Yang, you will see that it ends up with the common question:

Which callback function is appropriate choice if it’s such a case?

Which callback should I use?

I have to admit, in Simulink there are many callbacks available and it is not always obvious which one should be used for a specific task.

As you probably know, you have model callbacks and block callbacks.

For masked subsystems, you typically have two types of callbacks. For each parameter, you have a dialog callback:

Dialog callbacks

and you have initialization commands:

Mask Initialization

Even though they can sometime be interchanged, those two types of callback are intended for different use cases and using the wrong one can lead to unexpected behavior.

Best Practices for Masking

In R2012b, if you search the documentation for "masking examples", you will notice that the first result is:

Masking Examples

In the Best Practices for Masking page, there are detailed examples showing how to achieve common masking tasks:

Masking Examples

In your MATLAB installation, each of these links open a model with annotations and detailed comments in each callback to give you the starting point to develop your own masks.

Masking Examples

Now it's your turn

Give a look at the examples included in Best Practices for Masking and let us know if there are additional examples you would like to see by leaving a comment here

  • print
  • send email


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.