How do I programatically change a existing container type of a mask

26 Ansichten (letzte 30 Tage)
Emir
Emir am 17 Nov. 2025 um 9:59
Kommentiert: Fangjun Jiang am 18 Nov. 2025 um 18:44
Hi all,
how do I change programmatically this:
I have added a MATLAB Function to a Simulink file and clicked on the MATLAB Function and then run mask_it(gcb) see below
function mask_it(block)
maskObj = Simulink.Mask.get(block);
% If a mask already exists, delete it to ensure a clean slate before creating/reconfiguring
if ~isempty(maskObj)
maskObj.delete;
% Get the mask object again (it should be empty now)
maskObj = Simulink.Mask.get(block);
end
% Create the mask if it doesn't exist or was just deleted
if isempty(maskObj)
maskObj = Simulink.Mask.create(block);
end
% Define column headers for the table
% Note: 'Type' 'edit' applies to the entire column.
% 'Name' here refers to the column header, not the parameter name.
maskObj.addParameter('Type', 'edit', 'Name', 'param1', ...
'Prompt', 'params1', 'Value', '0', ...
'Tunable', 'on', 'Evaluate', 'on');
maskObj.addParameter('Type', 'edit', 'Name', 'param2', ...
'Prompt', 'params2', 'Value', '0', ...
'Tunable', 'on', 'Evaluate', 'on');
end
maskObj.set(???)
Many thanks in advance!

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 17 Nov. 2025 um 20:29
Try if you can play with this further, between "Group" or "Table"
>> maskobj=Simulink.Mask.get(gcb);
>> controls = maskobj.getDialogControls
controls =
1×2 heterogeneous Container (Group, Table) array with properties:
Enabled
Visible
AlignPrompts
DialogControls
Name
Tooltip
  2 Kommentare
Emir
Emir am 18 Nov. 2025 um 10:50
Verschoben: Fangjun Jiang am 18 Nov. 2025 um 12:53
Hi Fangjun,
I have played around a lot. The main problem is the the lack of documentation what is possible and what not. Topics as Level2 Matlab function and (its) mask are documented sparsly so I have days of trial and error. I hope a Mathworks expert can state if an existing container "Type" can be changed programmatically or not.
The methods and classes suggest: No, it is not possible. However, the GUI manages it so there are most like a methods of sets of methods that are executed in the background.
Fangjun Jiang
Fangjun Jiang am 18 Nov. 2025 um 18:44
I agree. If you really need that capability, maybe contact the Mathworks Tech support for help.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simulink Environment Customization finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by