📄 gui2_4.m
字号:
% GUI for Plotting facility
% Dr. P.Venkataraman Applied Optimization Using Matlab
%
% Ch.2 Sec. 2.4
%
% GUI is created within a figure window
%----------------------------------------------------------
Hfig_1 = figure; % Hfig_1 isthe handle to the figure window
set(Hfig_1, 'Color',[0.3,0.6,0.5], ... % set color
'NumberTitle','off', ... % no window title
'Name', 'Set Range for Design variables', ...
'Units','inches', ... % inches used to layout other controls
'Menubar','none', ...
'Position',[4,4,4.4,1.5]);
% Position property is [left, bottom, width, height] in Units selected
Ht_1 = uicontrol(Hfig_1, ...
'Style','text', ...
'Units','inches', ...
'Position',[0.1,1.1,2.4,.2], ...
'String','Number of Functions to Plot');
Ht_2 = uicontrol(Hfig_1, ...
'Style','edit', ...
'Units','inches', ...
'Position',[2.6,1.1,0.5,.2], ...
'BackgroundColor','white', ...
'String','', ...
'Callback','Np = str2num(get(Ht_2,''String''));');
HL_X1L = uicontrol(Hfig_1, ...
'Style','text', ...
'Units','inches', ...
'Position',[0.1,0.8,0.5,.2], ...
'String','x1(min)');
HT_X1L = uicontrol(Hfig_1, ...
'Style','edit', ...
'Units','inches', ...
'Position',[0.7,0.8,0.7,.2], ...
'BackgroundColor','white', ...
'String','', ...
'Callback','x1min = str2num(get(HT_X1L,''String''));');
HL_X1M = uicontrol(Hfig_1, ...
'Style','text', ...
'Units','inches', ...
'Position',[1.5,0.8,0.6,.2], ...
'String','increment');
HT_X1M = uicontrol(Hfig_1, ...
'Style','edit', ...
'Units','inches', ...
'Position',[2.2,0.8,0.7,.2], ...
'BackgroundColor','white', ...
'String','', ...
'Callback','x1inc = str2num(get(HT_X1M,''String''));');
HL_X1U = uicontrol(Hfig_1, ...
'Style','text', ...
'Units','inches', ...
'Position',[3.0,0.8,0.5,.2], ...
'String','x1(max)');
HT_X1U = uicontrol(Hfig_1, ...
'Style','edit', ...
'Units','inches', ...
'Position',[3.6,0.8,0.7,.2], ...
'BackgroundColor','white', ...
'String','', ...
'Callback','x1max = str2num(get(HT_X1U,''String''));');
HL_X2L = uicontrol(Hfig_1, ...
'Style','text', ...
'Units','inches', ...
'Position',[0.1,0.5,0.5,.2], ...
'String','x2(min)');
HT_X2L = uicontrol(Hfig_1, ...
'Style','edit', ...
'Units','inches', ...
'Position',[0.7,0.5,0.7,.2], ...
'BackgroundColor','white', ...
'String','', ...
'Callback','x2min = str2num(get(HT_X2L,''String''));');
HL_X2M = uicontrol(Hfig_1, ...
'Style','text', ...
'Units','inches', ...
'Position',[1.5,0.5,0.6,.2], ...
'String','increment');
HT_X2M = uicontrol(Hfig_1, ...
'Style','edit', ...
'Units','inches', ...
'Position',[2.2,0.5,0.7,.2], ...
'BackgroundColor','white', ...
'String','', ...
'Callback','x2inc = str2num(get(HT_X2M,''String''));');
HL_X2U = uicontrol(Hfig_1, ...
'Style','text', ...
'Units','inches', ...
'Position',[3.0,0.5,0.5,.2], ...
'String','x2(max)');
HT_X2U = uicontrol(Hfig_1, ...
'Style','edit', ...
'Units','inches', ...
'Position',[3.6,0.5,0.7,.2], ...
'BackgroundColor','white', ...
'String','', ...
'Callback','x2max = str2num(get(HT_X2U,''String''));');
Hlabel = uicontrol(Hfig_1, ...
'Style','text', ...
'Units','inches', ...
'Position',[0.1,0.1,2.2,.2], ...
'BackgroundColor','y', ...
'String','After entering values please press EXIT');
Hpush = uicontrol(Hfig_1,'Style','push', ...
'Units','inches', ...
'Position',[2.5,0.1,0.7,.2], ...
'BackgroundColor','red', ...
'String','EXIT', ...
'Callback','uiresume');
uiwait
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -