📄 test_button_group1.m
字号:
function test_button_group1
fig = figure;
pos = get(gcf,'Position');
pos(3) = 300;
pos(4) = 200;
set(gcf,'Position',pos,'NumberTitle','off','MenuBar','none', ...
'Name','Test Button Group','ToolBar','none');
h = uibuttongroup('visible','off','Position',[0.1 0.1 0.8 0.8],...
'Title','Button Group');
u0 = uicontrol('Style','Radio','String','Option 1',...
'Units','normalized', ...
'pos',[0.1 0.7 0.8 0.1],'parent',h,'HandleVisibility','off');
u1 = uicontrol('Style','Radio','String','Option 2',...
'Units','normalized', ...
'pos',[0.1 0.4 0.8 0.1],'parent',h,'HandleVisibility','off');
u2 = uicontrol('Style','Radio','String','Option 3',...
'Units','normalized', ...
'pos',[0.1 0.1 0.8 0.1],'parent',h,'HandleVisibility','off');
set(h,'SelectionChangeFcn',@selcbk);
set(h,'SelectedObject',[]); % No selection
set(h,'Visible','on');
end
function selcbk(source,eventdata)
disp(source);
disp([eventdata.EventName,' ',...
get(eventdata.OldValue,'String'),' ', ...
get(eventdata.NewValue,'String')]);
disp(get(get(source,'SelectedObject'),'String'));
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -