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 regardingMaskingandVariant Subsystems.

If you look atthis exchangeI 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 havemodel callbacksandblock 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 theBest Practices for Maskingpage, 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 inBest Practices for Maskingand let us know if there are additional examples you would like to see by leaving acomment here

|

댓글

댓글을 남기려면링크를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.