removeMember
R2026bSyntax
Description
Examples
Create a selection group that manages three toggle buttons.
fig = uifigure(Position=[100 100 200 200]); gl = uigridlayout(fig,[3 1]); tb1 = uitogglebutton(gl,Text="English"); tb2 = uitogglebutton(gl,Text="French"); tb3 = uitogglebutton(gl,Text="German"); sg = uiselectiongroup([tb1 tb2 tb3]);

Then remove the first button from the group. The removeMember function removes the button from the group but does not delete the button. By default, the first button in the modified selection group is selected. The original first button remains selected.
removeMember(sg,tb1);

Create a grid layout in a figure with seven radio buttons managed by a selection group and a check box.
fig = uifigure(Position=[100 100 800 100]); gl = uigridlayout(fig,[2 7]); rb1 = uiradiobutton(gl,Text="Monday"); rb2 = uiradiobutton(gl,Text="Tuesday"); rb3 = uiradiobutton(gl,Text="Wednesday"); rb4 = uiradiobutton(gl,Text="Thursday"); rb5 = uiradiobutton(gl,Text="Friday"); rb6 = uiradiobutton(gl,Text="Saturday"); rb7 = uiradiobutton(gl,Text="Sunday"); sg = uiselectiongroup([rb1 rb2 rb3 rb4 rb5 rb6 rb7]); cb = uicheckbox(gl,Text="Exclude Weekend"); cb.Layout.Column = [1 2];

Write a callback function named toggleWeekend that controls whether the Saturday and Sunday buttons are enabled and part of the selection group. This callback executes when a user interacts with the check box. Save the function in a folder that is on the MATLAB path.
function toggleWeekend(src,event,sg,rb6,rb7) if src.Value == 1 sg.removeMember([rb6 rb7]) rb6.Enable = "off"; rb7.Enable = "off"; elseif src.Value == 0 sg.addMember([rb6 rb7]) rb6.Enable = "on"; rb7.Enable = "on"; end end
cb.ValueChangedFcn = @(src,event) toggleWeekend(src,event,sg,rb6,rb7);

Input Arguments
Selection group, specified as a SingleSelectionGroup object created using the uiselectiongroup function.
Button to remove, specified as an array of RadioButton objects or
an array of ToggleButton objects. The specified buttons must be members
of the selection group sg.
Version History
Introduced in R2026b
See Also
Functions
Objects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)