Simulink Dialog Callback Executed Only When Dialog Parameter Is Changed

6 次查看(过去 30 天)
I am working on a Simulink model with masked subsystems. Here is my situation: I am using Dialog Callbacks for my masked parameters, but have noticed that a Mask Callback occurs simply by double clicking on the masked block to edit the paramters (found this out by turning on callback tracing). This creates overhead because nothing has changed yet and may not change (simploy by closing the window or clicking cancel). How do I force the Dialog Callback to only fire when I change a dialog parameter value by hitting Apply or OK?

回答(1 个)

Doug Eastman
Doug Eastman 2011-1-20
Hi Travis,
For code that you only want to execute when parameters change, you may want to put the code in the Initialization commands section in the Initialization pane.
From the doc:
"Initialization commands for all masked blocks in a model run when you:
  • Update the diagram.
  • Start simulation.
  • Start code generation.
Initialization commands for an individual masked block run when you:
  • Change any of the parameters that define the mask, such as MaskDisplay and MaskInitialization, by using the Mask Editor or set_param.
  • Change the appearance of the masked block, for example by resizing or rotating the block.
  • Change the value of a mask parameter by using the block dialog or set_param.
  • Copy the masked block within the same model or between different models."
Dialog Callback commands are generally intended only to update the dialog display for example by hiding or revealing parameters based on a check box or drop-down menu.
From the Doc: "You can use such [Dialog] callbacks to create dialog boxes that change in appearance depending on the changes the user makes to control settings, such as enabling an edit field when a user selects a check box."

类别

Help CenterFile Exchange 中查找有关 Author Block Masks 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by