Simulink_Masks - david-macmahon/wiki_convert_test GitHub Wiki

Definitions

A subsystem block in Simulink is analogous to a function in standard text-based programming languages. They help modularize large bodies of code and abstract away implementation details. This makes code easier to read, maintain, and extend. When a design grows too large, it's a good idea to start breaking it up into subsystems. Subsystem blocks are usually just referred to as blocks.

A block mask is a simplified user interface to internal block components. They allow you to modify the parameters of a block's internal components without looking at its underlying schematic. A block mask can have an associated mask script that runs whenever mask parameters change.

The Mask Editor is where you can customize the mask dialog box for a subsystem block. It is fully and concisely documented on the Mathworks website, so we won't duplicate their effort here. See the References section for a link.

Dialog Callbacks

In the Parameters tab of the Mask Editor, you can define variables that are local to your block. For each variable, you can define a callback function that will run whenever that variable is modified. Each variable type has a typical callback function structure. The following examples are meant to be used as templates for common tasks.

Edit

To be documented.

Checkbox

This is a general-purpose function for a checkbox variable named var_checkbox. It will enable or disable the variables var_x, var_y, and var_z in the block mask.

Dialog callback:

thisVariable = 'var_checkbox';
affectedVars = {'var_x', 'var_y', 'var_z'};

thisBlock = gcb();
thisVarState = get_param(thisBlock, thisVariable);
maskNames = get_param(thisBlock, 'MaskNames');
maskEnables = get_param(thisBlock, 'MaskEnables');

for varName = affectedVars
    varIndex = find(ismember(maskNames, varName));
    maskEnables{varIndex} = thisVarState;
end

set_param(thisBlock, 'MaskEnables', maskEnables);

Be sure that list items in affectedVars are separated by commas, not semicolons.

Popup

To be documented.

Mask Scripts

To be documented.

References