test_radiobutton.m

来自「基本的matlab编程源代码」· M 代码 · 共 48 行

M
48
字号
function test_radiobutton()
% This function creates a set of radio buttons and a 
% text field.  The the associated callback will cause 
% the text field to display the state of the radio 
% buttons.

h0 = figure('Color',[0.8 0.8 0.8], ...
   'Name','Test Radio Button', ...
   'NumberTitle','off', ...
   'Position',[300 300 257 136], ...
   'Tag','Fig1');
h1 = uicontrol('Parent',h0, ...
   'Units','points', ...
   'BackgroundColor',[0.8 0.8 0.8], ...
   'Position',[45 60 70 15], ...
   'String','Option 1', ...
   'Style','text', ...
   'Tag','Label1');
h1 = uicontrol('Parent',h0, ...
   'Units','points', ...
   'Position',[40 5 80 55], ...
   'Style','frame', ...
   'Tag','Frame1');
h1 = uicontrol('Parent',h0, ...
   'Units','points', ...
   'Callback','test_radiobutton_callback rb1', ...
   'Position',[45 40 70 15], ...
   'String','Option 1', ...
   'Style','radiobutton', ...
   'Value',1, ...
   'Tag','radiobutton1');
h1 = uicontrol('Parent',h0, ...
   'Units','points', ...
   'Callback','test_radiobutton_callback rb2', ...
   'Position',[45 25 70 15], ...
   'String','Option 2', ...
   'Style','radiobutton', ...
   'Value',0, ...
   'Tag','radiobutton2');
h1 = uicontrol('Parent',h0, ...
   'Units','points', ...
   'Callback','test_radiobutton_callback rb3', ...
   'Position',[45 10 70 15], ...
   'String','Option 3', ...
   'Style','radiobutton', ...
   'Value',0, ...
   'Tag','radiobutton3');

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?