Cannot change "MaskValues" parameter

2 次查看(过去 30 天)
I have created a LED indicator library which uses a mask. The LED can change color based on different input values. The condition when to change color can be set within a self created mask parameters dialog and a dropdown box is used to select the state you want to change conditions for. See the image below for an example:
So, when I change the "Show parameters for condition", the edit boxes prompts and values of "Condition no.2 lower limit" should change to its corresponding value. Same holds for upper limit and the color. To achieve this, I use the following lines in a callback function of the dropdown box:
set_param(currBlk,'MaskPrompts',maskPrompts)
set_param(currBlk,'MaskVisibilities',maskVis)
set_param(currBlk,'MaskValues',maskValues)
where maskPrompts, maskVis and maskValues are cell arrays with the correct values and currBlk is the handle to mask parameters dialog. However, when I execute the last line, the values do not change. That is, when I execute the set_param line and execute
get_param(currBlk,'MaskValues')
the values are unchanged. MaskPrompts and MaskVisiblities are working fine. In Matlab 6.5 this used to work fine, but in Matlab 2015b this does not seem to work anymore. Is there any settings that blocks change of this setting? I already tried to enable the "Evaluate" and "Tunable" settings for these controls, but this doesn't seem to have any effect.
Any suggestions?

采纳的回答

Paulus Potter
Paulus Potter 2016-12-1
编辑:Paulus Potter 2016-12-1
Had contact with Mathworks. It appears that from Matlab 2014b, setting the 'MaskValues' through set_param in a callback function is not possible anymore. The work around is to set the parameter of each dialog control individually:
% Retrieve all dialog control names
controlNames = fieldnames(get_param(currBlk,'DialogParameters'));
for i=1:length(controlNames)
set_param(currBlk,controlNames{i},my_values_cell{i})
end
This works!

更多回答(1 个)

Ganesh Hegade
Ganesh Hegade 2016-11-30
编辑:Ganesh Hegade 2016-11-30
Hi,
Please try to get the object of the block and assign the properties and check.
oBlock = eval(LED);
oBlock.SetPropertyList([maskPrompts, maskValues])

类别

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