You can create icons that update when you change the mask parameters to reflect the purpose of the block. This example shows how to use drawing commands to create a mask icon.
A static mask icon remains unchanged, independent of the value of the mask parameters.
Select the masked block that requires the icon.
On the Block tab, in the Mask group, click Edit Mask.
In the Icons & Ports tab, enter this command in the Icon Drawing commands pane:
% Use specified image as mask icon image('engine.jpg')
The image file must be on the MATLAB® path.
For more examples of drawing command syntax, see Icon drawing commands.
Images in formats .cur
, .hdf4
,
.ico
, .pcx
, .ras
,
.xwd
, .svg
cannot be used as block mask
images. However, you can use images in these formats if you wrap the file name in the
imread()
function and use the RGB triplet. Using the
imread()
function is not efficient. However, it is still
supported for backward compatibility.
A dynamic icon changes with the values of the mask parameters. Use it to represent the purpose of the masked block.
Select the masked block that requires the icon.
On the Block tab, in the Mask group, click Edit Mask.
The Mask Editor opens.
In the Icons & Ports tab, enter this command in the Icon Drawing commands pane:
pos = get_param(gcb, 'Position'); width = pos(3) - pos(1); x = [0, width]; y = m*x + b; % Parameters 'm' and 'b' must be defined in 'Parameters & Dialog' pane. plot(x,y)
Under Options, set Icon Units to
Pixels
.
The drop-down lists under Options allow you to specify icon frame visibility, icon transparency, drawing context, icon rotation, and port rotation.
Click Apply. To view the icon generated, see model
masking_example
.
Note
If Simulink® cannot evaluate all commands in the Icon Drawing
commands pane to generate an icon, three question marks (? ?
?
) appear on the mask.
See slexMaskDisplayAndInitializationExample
for more examples of icon
drawing commands. This model shows how to draw:
Static mask
Dynamic shape mask
Dynamic text mask
Image mask