test_button_group1.m
来自「matlab programming for engineers(2nd)书籍源」· M 代码 · 共 31 行
M
31 行
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 + =
减小字号Ctrl + -
显示快捷键?