📄 preprocess.m
字号:
endfor i=1:length(names) if isempty(names{i}) | isspace(names{i}) bool = 0; return; endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Subfunction: isvalid_var_name %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function bool=isvalid_var_name(name)bool=1;tmp=name{1};if ~((tmp(1)>='a' & tmp(1)<='z') | (tmp(1)>='A' & tmp(1)<='Z')) errordlg('Invalid name.'); bool=0; return;endfor j=1:length(tmp) if ~((tmp(j)>='a' & tmp(j)<='z') | ... (tmp(j)>='A' & tmp(j)<='Z') | ... (j>1 & tmp(j) == '_') | ... (tmp(j)>='0' & tmp(j) <= '9')) | tmp(j) == '.' errordlg('Invalid name.'); bool=0; return; end if j == length(tmp) & tmp(j) == '_' errordlg('Invalid name.'); bool=0; return; endend %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Subfunction: copy_delete %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function copy_delete(arg)i=1;while i <= length(arg) & arg(i) ~= ' ' i=i+1;endarg2=arg(i+1:length(arg));arg=arg(1:i-1);if ~isempty(arg2) index=str2num(arg2); LOG=1;else LOG=0;endsets_h=getfield(get(gcf,'UserData'),'sets_h');if ~LOG index=get(sets_h,'Value');endpre_h=findobj(get(0,'Children'),'Tag','Preprocess');if isempty(pre_h) errordlg('''Preprocess'' -figure does not exist. Terminating program.'); close_preprocess; return;endswitch arg case 'copy' data=get(pre_h,'UserData'); data.sD_set(length(data.sD_set)+1)=data.sD_set(index); if ~LOG data.LOG{length(data.LOG)+1}='% Copy a data set.'; data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''copy_delete'',''',... 'copy ',num2str(index),''');'); end set(pre_h,'UserData',data); sD_names; old=gcf; set(0,'CurrentFigure',pre_h); set_sD_stats; set(0,'CurrentFigure',old); case 'delete' if length(get(sets_h,'String')) == 1 msgbox('No data left. Closing program...') close_preprocess; return; end data=get(pre_h,'UserData'); if ~isempty(data.undo) & any(strcmp('index',fieldnames(data.undo))) if data.undo.index > index data.undo.index = data.undo.index-1; elseif data.undo.index==index; data.undo=[]; end end set1=data.sD_set(1:index-1); set2=data.sD_set(index+1:length(data.sD_set)); if ~isempty(set1) data.sD_set=[set1 set2]; else data.sD_set=set2; end if ~LOG data.LOG{length(data.LOG)+1}='% Delete a data set.'; data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''copy_delete'',''',... 'delete ',num2str(index),''');'); end set(pre_h,'UserData',data); set(sets_h,'Value',1); sD_names; sD_stats; old = gcf; set(0,'CurrentFigure',pre_h); for i=1:length(data.sD_set) string{i}=cat(2,sprintf('#%d: ',i),data.sD_set(i).name); end set(data.sD_set_h,'String',string); data.sData=data.sD_set(get(data.sD_set_h,'Value')); data.sData.MODIFIED=0; data.sData.INDEX=1; set(gcf,'UserData',data); write_sD_stats; sData=getfield(get(gcf,'UserData'),'sData'); if sData.INDEX > index value=get(getfield(get(gcf,'UserData'),'sD_set_h'),'Value'); set(getfield(get(gcf,'UserData'),'sD_set_h'),'Value',value-1); sData.INDEX = sData.INDEX -1; elseif sData.INDEX == index set(getfield(get(gcf,'UserData'),'sD_set_h'),'Value',1); end sel_sD; set(0,'CurrentFigure',old);end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function clipping(varargin)if nargin ~= 1 pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); preh_udata=get(pre_h,'UserData'); preh_udata.LOG{length(preh_udata.LOG)+1}=... '% Starting the ''Clipping'' -window...'; preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''clipping'',''foo'');'; set(pre_h,'UserData',preh_udata);endclip_h=findobj(get(0,'Children'),'Tag','Clipping');if ~isempty(clip_h) figure(clip_h); return;endh0 = figure('Color',[0.8 0.8 0.8], ... 'PaperPosition',[18 180 575 432], ... 'PaperUnits','points', ... 'Position',[718 389 300 249], ... 'Tag','Clipping');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... 'ListboxTop',0, ... 'Position',[0.03 0.03614457831325301 0.4666666666666667 0.9236947791164658], ... 'Style','frame', ... 'Tag','Frame1');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'ListboxTop',0, ... 'Position',[0.05333333333333334 0.5983935742971887 0.42 0.3333333333333333], ... 'Style','frame', ... 'Tag','Frame2');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'ListboxTop',0, ... 'Style','frame', ... 'Position',[0.05333333333333334 0.33 0.42 0.24], ... 'Tag','Frame3');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'ListboxTop',0, ... 'Style','frame', ... 'Position',[0.05333333333333334 0.06 0.42 0.24],... 'Tag','Frame4');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'ListboxTop',0, ... 'Position',[0.5133333333333334 0.6385542168674698 0.4666666666666667 0.321285140562249], ... 'Style','frame', ... 'Tag','Frame5');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'ListboxTop',0, ... 'Position',[0.5366666666666667 0.6666666666666666 0.42 0.2650602409638554], ... 'Style','frame', ... 'Tag','Frame6');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[0.31 0.823293172690763 0.15 0.09638554216867469], ... 'Style','edit', ... 'Tag','EditText1');data.big_val_h = h1;h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[0.31 0.7148594377510039 0.15 0.09638554216867469], ... 'Style','edit', ... 'Tag','EditText2');data.small_val_h = h1;h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[0.31 0.606425702811245 0.15 0.09638554216867469], ... 'Style','edit', ... 'Tag','EditText3');data.equal_val_h=h1;h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',6, ... 'FontWeight','demi', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.06000000000000001 0.8473895582329316 0.22 0.05622489959839357], ... 'String','Bigger than', ... 'Style','text', ... 'Tag','StaticText1');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',6, ... 'FontWeight','demi', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.06000000000000001 0.7389558232931727 0.24 0.04819277108433735], ... 'String','Smaller than', ... 'Style','text', ... 'Tag','StaticText2');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',6, ... 'FontWeight','demi', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.06000000000000001 0.610441767068273 0.22 0.07228915662650602], ... 'String','Equal to', ... 'Style','text', ... 'Tag','StaticText3');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'ListboxTop',0, ... 'Position',[0.07000000000000001 0.465863453815261 0.06333333333333334 0.07228915662650602], ... 'Style','radiobutton', ... 'Value',1,... 'Tag','Radiobutton1');data.and_button_h=h1;h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'ListboxTop',0, ... 'Position',[0.07000000000000001 0.3734939759036144 0.06333333333333334 0.07228915662650602], ... 'Style','radiobutton', ... 'Tag','Radiobutton2');data.or_button_h=h1;h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',6, ... 'FontWeight','demi', ... 'HorizontalAlignment','left', ... 'Position',[0.1466666666666667 0.45 0.2333333333333333 0.07228915662650602], ... 'String','AND', ... 'Style','text', ... 'Tag','StaticText4');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',6, ... 'FontWeight','demi', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'String','OR', ... 'Position',[0.1466666666666667 0.35 0.2333333333333333 0.07228915662650602], ... 'Style','text', ... 'Tag','StaticText5');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'ListboxTop',0, ... 'Position',[0.07000000000000001 0.1967871485943775 0.06333333333333334 0.07228915662650602], ... 'Style','radiobutton', ... 'Value',1,... 'Tag','Radiobutton3');data.all_button_h=h1;h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'ListboxTop',0, ... 'Position',[0.07000000000000001 0.09236947791164658 0.06333333333333334 0.07228915662650602], ... 'Style','radiobutton', ... 'Tag','Radiobutton4');data.sel_vects_button_h=h1;h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',6, ... 'FontWeight','demi', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.1466666666666667 0.1927710843373494 0.2333333333333333 0.07228915662650602], ... 'String','All vectors', ... 'Style','text', ... 'Tag','StaticText6');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',6, ... 'FontWeight','demi', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.1466666666666667 0.09638554216867469 0.3133333333333334 0.05622489959839357], ... 'String','Among selected', ... 'Style','text', ... 'Tag','StaticText7');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[0.7866666666666667 0.823293172690763 0.1366666666666667 0.09236947791164658], ... 'Style','edit', ... 'Tag','EditText4');data.replace_val_h=h1;h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',6, ... 'FontWeight','demi', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.5633333333333334 0.8273092369477911 0.2066666666666667 0.07630522088353413], ... 'String','Replace', ... 'Style','text', ... 'Tag','StaticText8');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'FontWeight','demi', ... 'ListboxTop',0, ... 'Position',[0.5700000000000001 0.6827309236947791 0.3566666666666667 0.08032128514056225], ... 'String','Replace', ... 'Tag','Pushbutton1');data.OK_button_h=h1;h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... 'Callback','preprocess close_c',... 'FontWeight','demi', ... 'ListboxTop',0, ... 'Position',[0.6633333333333333 0.07228915662650602 0.2833333333333333 0.09638554216867469], ... 'String','Close', ... 'Tag','Pushbutton2');data.state.and=1;data.state.all=1;data.state.big=[];data.state.small=[];data.state.equal=[];data.state.replace=[];set(data.or_button_h,'Callback','preprocess and_or_cb or');set(data.and_button_h,'Callback','preprocess and_or_cb and');set(data.and_button_h,'Value',1);set(data.all_button_h,'Callback','preprocess all_sel_cb all');set(data.sel_vects_button_h,'Callback','preprocess all_sel_cb sel');set(data.big_val_h,'Callback','preprocess set_state_vals big');set(data.small_val_h,'Callback','preprocess set_state_vals small');set(data.equal_val_h,'Callback','preprocess set_state_vals equal');set(data.replace_val_h,'Callback','preprocess set_state_vals replace');set(data.OK_button_h,'Callback','preprocess clip_data clip');set(h0,'UserData',data);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function select(varargin)if nargin ~= 1 pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); preh_udata=get(pre_h,'UserData'); preh_udata.LOG{length(preh_udata.LOG)+1}=... '% Starting the ''Select'' -window...'; preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''select'',''foo'');'; set(pre_h,'UserData',preh_udata);endsel_h=findobj(get(0,'Children'),'Tag','Select');if ~isempty(sel_h) figure(sel_h); return;endh0 = figure('Color',[0.8 0.8 0.8], ... 'PaperPosition',[18 180 576 432], ... 'PaperUnits','points', ... 'Position',[750 431 168 365], ... 'Tag','Select');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... 'ListboxTop',0, ... 'Position',[0.05357142857142857 0.2712328767123288 0.8333333333333333 0.6301369863013698], ... 'Style','frame', ... 'Tag','Frame1');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... 'ListboxTop',0, ... 'Position',[0.05357142857142857 0.1041095890410959 0.8333333333333333 0.1397260273972603], ... 'Style','frame', ... 'Tag','Frame2');h1 = uicontrol('Parent',h0,... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'ListboxTop',0, .
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -