How do you change the values of a mask parameter edit box programatically and have them visually update when changes are applied to the mask?
3 次查看(过去 30 天)
显示 更早的评论
For example, I have created a mask with a parameter edit box that allows me to input a value for a variable inside the subsystem. The mask also contains initialization code (more specifically a function) that calculates the value for other variables in the mask based on input variables. I would like for those newly calculated variables to appear in their respective parameter edit box when changes are applied to the mask. Less specifically, I would like the mask to update itself with those values when changes are applied. I hope this is a satisfactory explanation of the problem.
I have tried using the following code, which seems correct but will not update the mask parameter edit boxes. K and Ra are arbitrary variables calculated by a function inside the initialization of the mask.
values = get_param(gcb,'MaskValues');
values(3) = {num2str(K)};
values(4) = {num2str(Ra)};
set_param(gcb,'MaskValues',values);
I was able to use similar code to update the enable parameter of parameter edit boxes in the dialog box.
param_enable = get_param(gcb,'MaskEnables');
param_enable(3) = {'on'}; %torque/back EMF constant
param_enable(4) = {'on'}; %armature resistance
param_enable(7) = {'off'}; %voltage
param_enable(8) = {'off'}; %max power
param_enable(9) = {'off'}; %no load speed
set_param(gcb,'MaskEnables',param_enable)
This code worked successfully but the previous code did not. Quite frankly it doesnt make sense.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Author Block Masks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!