📄 nonneg_param.m
字号:
% nonneg_param.m% Setup gui parameters:% ttlbarcorrects vertical spacing by adjusting for title bar height. ttlbar = [0 75 0 0]; rowheight = [0 25 0 0]; % The vertical space required for a control (20 + 5) guifigsize = [20 scrn(4)-350 350 375]-ttlbar; guifigy = guifigsize(4)-20; %%% Resize window set(guifig,'position',guifigsize); % set "first" control positions a1size = [0 guifigsize(4)-65 floor(1/2*guifigsize(3)) 20]; b1size = [a1size(3)+3 guifigsize(4)-65 floor(1/6*guifigsize(3)) 20];% set data_name and data_size control positions % datasetuppos positions the text that reflects the current data set% datasizepos positions the text that reflects the current data set size (n by n) datasetuppos = [0 guifigy 2/3*guifigsize(3) 20]; datasizepos = [datasetuppos(3) guifigy 1/3*guifigsize(3) 20];% Set parameters and stopping tolerances. N = nx*ny; reg_order = 0; alpha = 1e-8; newt_maxiter = 4; newt_steptol = 1e-4; newt_gradtol = 1e-4; newt_tab_flag = 1; GA_param = 1e-4; % Used in Goldstein-Armijo like line search condition ls_maxiter = 10; % Max. no. of backtracks allowed in line search. tol0 = 1e-2; % Used to set active set tolerance. cg_maxiter = n/2; cg_steptol = 1e-4; cg_residtol = 1e-4; cg_tab_flag = 1; bh = Kstarz * (hx*hy);% Check for existence (figure_list(i)>0) of figure. If figure does not exist,% determine the appropriate figure number and store in figure_list.lastfig = max(findobj('type', 'figure'));if ( figure_list(7) > 0 ) cg_fig = figure_list(7);else cg_fig = lastfig + 1; lastfig = lastfig + 1; figure_list(7) = cg_fig;end%% After above (if else end), lastfig is the last figure handle.%% Technically, the "last figure" may not be created yet; but we keep track%% as if it were.if ( figure_list(8) > 0 ) newt_fig = figure_list(8);else % newt_fig = lastfig + 1; figure_list(8) = newt_fig;end% Setup the Graphic Controls for NONNEG methodeval(hideall);set(ui_a16, ... 'style','text', ... 'string',datasetupflag, ... 'position',datasetuppos, ... 'backgroundcolor',bgcolor, ... 'foregroundcolor',[0 0 0], ... 'visible','on');set(ui_b16, ... 'string',[num2str(max(size(z))), ' by ', num2str(max(size(z))) ], ... 'style','text', ... 'position',datasizepos, ... 'backgroundcolor',bgcolor, ... 'foregroundcolor',[0 0 0], ... 'visible','on');% controls for parameter reg_orderset(ui_a1, ... 'backgroundcolor',bgcolor, ... 'foregroundcolor',[1 1 1], ... 'style','text',... 'string','Regularization order', ... 'horizontalalignment','right',... 'position',a1size, ... 'visible','on');reg_order_action = ['reg_orderm = get(ui_b1,''value'');' , ... 'if reg_orderm==1,' , ... 'reg_order = 0;' , ... 'else,' , ... 'reg_order = 1;' , ... 'end'];set(ui_b1, ... 'backgroundcolor',[1 1 1], ... 'foregroundcolor',[0 0 0], ... 'style','popupmenu',... 'string','0|1', ... 'horizontalalignment','center',... 'position',b1size, ... 'callback',reg_order_action,... 'value',0,... 'visible','on');% controls for parameter alphaset(ui_a2, ... 'backgroundcolor',bgcolor,... 'foregroundcolor',[1 1 1], ... 'style','text',... 'horizontalalignment','right',... 'string','Reg param alpha =',... 'position',a1size-rowheight, ... 'visible','on');ui_b2_action = ['alpha=str2num(get(ui_b2,''string''));'];set(ui_b2, ... 'position',b1size-rowheight, ... 'backgroundcolor',[1 1 1],... 'style','edit',... 'string',num2str(alpha),... 'callback',ui_b2_action,... 'visible','on');% controls for parameter newt_maxiterset(ui_a3, ... 'backgroundcolor',bgcolor,... 'foregroundcolor',[1 1 1], ... 'style','text',... 'horizontalalignment','right',... 'string','Newton iter max =',... 'position',a1size-2*rowheight, ... 'visible','on');ui_b3_action = ['newt_maxiter=str2num(get(ui_b3,''string''));'];set(ui_b3, ... 'position',b1size-2*rowheight, ... 'backgroundcolor',[1 1 1],... 'style','edit',... 'string',num2str(newt_maxiter),... 'callback',ui_b3_action,... 'visible','on');% controls for parameter newt_steptolset(ui_a4, ... 'backgroundcolor',bgcolor,... 'foregroundcolor',[1 1 1], ... 'style','text',... 'horizontalalignment','right',... 'string','Newton step tol =',... 'position',a1size-3*rowheight, ... 'visible','on');ui_b4_action = ['newt_steptol=str2num(get(ui_b4,''string''));'];set(ui_b4, ... 'position',b1size-3*rowheight, ... 'backgroundcolor',[1 1 1],... 'style','edit',... 'string',num2str(newt_steptol),... 'callback',ui_b4_action,... 'visible','on');% controls for parameter newt_gradtolset(ui_a5, ... 'backgroundcolor',bgcolor,... 'foregroundcolor',[1 1 1], ... 'style','text',... 'horizontalalignment','right',... 'string','Newton grad tol =',... 'position',a1size-4*rowheight, ... 'visible','on');ui_b5_action = ['newt_gradtol=str2num(get(ui_b5,''string''));']; set(ui_b5, ... 'position',b1size-4*rowheight, ... 'backgroundcolor',[1 1 1],... 'style','edit',... 'string',num2str(newt_gradtol),... 'callback',ui_b5_action,... 'visible','on');% controls for parameter GA_paramset(ui_a6, ... 'backgroundcolor',bgcolor,... 'foregroundcolor',[1 1 1], ... 'style','text',... 'horizontalalignment','right',... 'string','GA_param',... 'position',a1size-5*rowheight, ... 'visible','on');ui_b6_action = ['GA_param=str2num(get(ui_b6,''string''));']; set(ui_b6, ... 'position',b1size-5*rowheight, ... 'backgroundcolor',[1 1 1],... 'style','edit',... 'string',num2str(GA_param),... 'callback',ui_b6_action,... 'visible','on');% controls for parameter ls_maxiter set(ui_a7, ... 'backgroundcolor',bgcolor,... 'foregroundcolor',[1 1 1], ... 'style','text',... 'horizontalalignment','right',... 'string','ls_maxiter',... 'position',a1size-6*rowheight, ... 'visible','on');ui_b7_action = ['ls_maxiter=str2num(get(ui_b7,''string''));']; set(ui_b7, ... 'position',b1size-6*rowheight, ... 'backgroundcolor',[1 1 1],... 'style','edit',... 'string',num2str(ls_maxiter),... 'callback',ui_b7_action,... 'visible','on');% controls for parameter tol0 set(ui_a8, ... 'backgroundcolor',bgcolor,... 'foregroundcolor',[1 1 1], ... 'style','text',... 'horizontalalignment','right',... 'string','tol0',... 'position',a1size-7*rowheight, ... 'visible','on');ui_b8_action = ['tol0=str2num(get(ui_b8,''string''));']; set(ui_b8, ... 'position',b1size-7*rowheight, ... 'backgroundcolor',[1 1 1],... 'style','edit',... 'string',num2str(tol0),... 'callback',ui_b8_action,... 'visible','on');% controls for parameter cg_maxiterset(ui_a9, ... 'backgroundcolor',bgcolor, ... 'foregroundcolor',[1 1 1], ... 'style','text',... 'string','cg max iter', ... 'horizontalalignment','right',... 'position',a1size-9*rowheight, ... 'visible','on');cgmax_action = ['cg_maxiter=str2num(get(ui_b9,''string''));'];set(ui_b9, ... 'backgroundcolor',[1 1 1], ... 'foregroundcolor',[0 0 0], ... 'style','edit',... 'string',num2str(cg_maxiter), ... 'horizontalalignment','right',... 'position',b1size-9*rowheight, ... 'callback',cgmax_action,... 'visible','on');% controls for parameter cg_steptolset(ui_a10, ... 'backgroundcolor',bgcolor, ... 'foregroundcolor',[1 1 1], ... 'style','text',... 'string','cg step tol', ... 'horizontalalignment','right',... 'position',a1size-10*rowheight, ... 'visible','on');cgsteptol_action = ['cg_steptol=str2num(get(ui_b10,''string''));'];set(ui_b10, ... 'backgroundcolor',[1 1 1], ... 'foregroundcolor',[0 0 0], ... 'style','edit',... 'string',num2str(cg_steptol), ... 'horizontalalignment','right',... 'position',b1size-10*rowheight, ... 'callback',cgsteptol_action,... 'visible','on');% controls for parameter cg_residtolset(ui_a11, ... 'backgroundcolor',bgcolor, ... 'foregroundcolor',[1 1 1], ... 'style','text',... 'string','cg resid tol', ... 'horizontalalignment','right',... 'position',a1size-11*rowheight, ... 'visible','on');cgresidtol_action = ['cg_residtol=str2num(get(ui_b11,''string''));'];set(ui_b11, ... 'backgroundcolor',[1 1 1], ... 'foregroundcolor',[0 0 0], ... 'style','edit',... 'string',num2str(cg_residtol), ... 'horizontalalignment','right',... 'position',b1size-11*rowheight, ... 'callback',cgresidtol_action,... 'visible','on');frbgcolor = [1 1 1];set(ui_frame_r, 'position',[guifigsize(3)-110 210 106 120], ... 'backgroundcolor',frbgcolor,... 'style','frame',... 'visible','on');% other controls are placed relative to the exitbtn% Thus, we define the exitbtnpos here.exitbtnpos = [guifigsize(3)-105 5 95 20];cg_tab_text_size = [guifigsize(3)-105 5 60 20]+7*rowheight;cg_tab_radio_size = [guifigsize(3)-45 5 18 18]+7*rowheight;%Text label "Tabular Output"set(ui_a17, ... 'backgroundcolor',frbgcolor,... 'foregroundcolor',bgcolor, ... 'style','text',... 'horizontalalignment','center',... 'string','Tabular Output', ... 'position',exitbtnpos+12*rowheight, ... 'visible','on');% controls for parameter cg_tab (cg tabular output on or off)set(ui_a18, ... 'backgroundcolor',frbgcolor,... 'foregroundcolor',[0 0 0], ... 'style','text',... 'horizontalalignment','right',... 'string','CG ', ... 'position',cg_tab_text_size+4*rowheight, ... 'visible','on');cg_tab_action = ... ['if get(ui_b18,''value'')==1,'... 'cg_tab_flag=1;' ... 'else,' ... 'cg_tab_flag=0;' ... 'end'];set(ui_b18, ... 'position',cg_tab_radio_size+4*rowheight, ... 'backgroundcolor',frbgcolor,... 'style','checkbox',... 'callback',cg_tab_action,... 'value',1, ... 'visible','on');% controls for parameter newt_tab (newton tabular output on or off)set(ui_a19, ... 'backgroundcolor',frbgcolor,... 'foregroundcolor',[0 0 0], ... 'style','text',... 'horizontalalignment','right',... 'string','Newton ', ... 'position',cg_tab_text_size+3*rowheight, ... 'visible','on');newt_tab_action = ... ['if get(ui_b19,''value'')==1,'... 'newt_tab_flag=1;' ... 'else,' ... 'newt_tab_flag=0;' ... 'end'];set(ui_b19, ... 'position',cg_tab_radio_size+3*rowheight, ... 'backgroundcolor',frbgcolor,... 'style','checkbox',... 'callback',newt_tab_action,... 'value',1, ... 'visible','on');% buttons run/break/closeuirunbtn_action = ['set(uirunbtn,''string'',''Working''),',... 'set(uirunbtn,''backgroundcolor'',[1 .5 0]),', ... 'nonneg_driver,', ... 'set(uirunbtn,''backgroundcolor'',green),', ... 'set(uirunbtn,''string'',''Run NonNeg'')'];set(uirunbtn, ... 'position', exitbtnpos+2*rowheight, ... 'callback',uirunbtn_action, ... 'string','Run NonNeg', ... 'backgroundcolor',green, ... 'visible','on');set(uibreakbtn, ... 'visible','on', ... 'callback','nonneg_param,dbquit', ... 'position',exitbtnpos+rowheight);set(uiexitbtn, ... 'pos', exitbtnpos, ... 'visible','on');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -