I have a Variant Subsystem. The variant control mode is Label. I'd like to have a popup mask parameter named LabelToActivate to set the active variant choice because my users know how to interact with a mask dialog box and don't know how to use variants (i.e. right-clicking the variant badge or right-clicking the block and navigating to Variant > Label Mode Active Choice).
The code I would put in MaskInitialization is straight-forward. This would run whenever the user applies mask changes.
set_param(gcb, 'LabelModeActiveChoice', LabelToActivate)
However, I don't want to hard-code the TypeOptions of the popup. When the block's LoadFcn callback executes, I want to get all of the labels and set the TypeOptions property of the mask parameter LabelToActivate. I thought there would be a block parameter like VariantControlLabels that I could read. The code in LoadFcn would look something like this…
% Get variant control labels.
labels = get_param(gcb, 'VariantControlLabels');% Set popup TypeOptions.
m = Simulink.Mask.get(gcb); %my mask
p = m.getParameter('LabelToActivate'); %my popup parameter
p.set('TypeOptions', labels)
Sadly, VariantControlLabels doesn't exist. I can't seem to find any property that stores all of the labels as a cell array of character vectors. Somehow the 'Variant choices' table in the Block Parameters dialog shows the labels in the 2nd column so where are those strings stored?
Best Answer