www.gusucode.com > Matlab动力系统和时间序列分析工具箱 > Matlab动力系统和时间序列分析工具箱/lab432/gui/gui_ssa_grouping.m
function varargout = gui_ssa_grouping(varargin) % GUI_SSA_GROUPING grouping elementary vectors in the sets % Last Modified by GUIDE v2.5 10-Feb-2004 20:16:42 % last modified 11.02.05 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @gui_ssa_grouping_OpeningFcn, ... 'gui_OutputFcn', @gui_ssa_grouping_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin & isstr(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before gui_ssa_grouping is made visible. function gui_ssa_grouping_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to gui_ssa_grouping (see VARARGIN) % Choose default command line output for gui_ssa_grouping handles.output = hObject; % Update handles structure guidata(hObject, handles); global GSD_GLOBALS GSD_GLOBALS.advanced_fig_handles=[GSD_GLOBALS.advanced_fig_handles hObject]; if isempty(get(handles.avail_triplet,'string')) set([handles.add handles.add_all handles.new_group],'enable','off'); end % UIWAIT makes gui_ssa_grouping wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = gui_ssa_grouping_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure try varargout{1} = handles.output; catch end % --- Executes during object creation, after setting all properties. function avail_triplet_CreateFcn(hObject, eventdata, handles) % hObject handle to avail_triplet (see GCBO) % handles empty - handles not created until after all CreateFcns called global SSA if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end str={}; if isempty(SSA.groups) for i=1:length(SSA.singular_numbers) str{i}=num2str(i); end else avail=1:length(SSA.singular_numbers); for i=1:length(SSA.groups) for j=1:length(SSA.groups{i}) avail(SSA.groups{i}(j))=0; end end avail=avail(find(avail>0)); for i=1:length(avail) str{i}=num2str(avail(i)); end end set(hObject,'string',str); % --- Executes on selection change in avail_triplet. function avail_triplet_Callback(hObject, eventdata, handles) % hObject handle to avail_triplet (see GCBO) % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns avail_triplet contents as cell array % contents{get(hObject,'Value')} returns selected item from avail_triplet % --- Executes during object creation, after setting all properties. function curr_group_CreateFcn(hObject, eventdata, handles) % hObject handle to curr_group (see GCBO) % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. global SSA if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end curr_group=1; str={}; if ~isempty(SSA.groups) for i=1:length(SSA.groups{curr_group}) str{i}=num2str(SSA.groups{curr_group}(i)); end end set(hObject,'string',str); % --- Executes on selection change in curr_group. function curr_group_Callback(hObject, eventdata, handles) % hObject handle to curr_group (see GCBO) % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns curr_group contents as cell array % contents{get(hObject,'Value')} returns selected item from curr_group % --- Executes during object creation, after setting all properties. function groups_CreateFcn(hObject, eventdata, handles) % hObject handle to groups (see GCBO) % handles empty - handles not created until after all CreateFcns called global SSA if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end str={}; group_counter=1; k=1; if ~isempty(SSA.groups) for i=1:length(SSA.groups) if ~isempty(SSA.groups{i}) substr=['group ' num2str(group_counter) ': ']; for j=1:length(SSA.groups{i})-1 substr=[substr num2str(SSA.groups{i}(j)) ', ']; end if isempty(j) j=0; end substr=[substr num2str(SSA.groups{i}(j+1))]; group_counter=group_counter+1; str{k}=substr; k=k+1; end end end set(hObject,'string',str); % --- Executes on selection change in groups. function groups_Callback(hObject, eventdata, handles) % hObject handle to groups (see GCBO) % Hints: contents = get(hObject,'String') returns groups contents as cell array % contents{get(hObject,'Value')} returns selected item from groups global SSA if isempty(SSA.groups) return end curr_group=get(hObject,'Value'); str={}; for i=1:length(SSA.groups{curr_group}) str{i}=num2str(SSA.groups{curr_group}(i)); end set(handles.curr_group,'value',min([1 length(str)])); set(handles.curr_group,'string',str); if ~isempty(str) set(handles.remove,'enable','on'); else set(handles.remove,'enable','off'); end % --- Executes on button press in add. function add_Callback(hObject, eventdata, handles) % hObject handle to add (see GCBO) global SSA str=get(handles.avail_triplet,'string'); val=get(handles.avail_triplet,'value'); if isempty(get(handles.groups,'string')) new_group_Callback(handles.new_group, eventdata, handles); end str_curr=get(handles.curr_group,'string'); str_curr={str_curr{:} str{val}}; set(handles.curr_group,'value',length(str_curr)); set(handles.curr_group,'string',str_curr); k=1; new_triplet_str={}; for i=1:length(str) if i~=val new_triplet_str{k}=str{i}; k=k+1; end end set(handles.avail_triplet,'value',min([val length(new_triplet_str)])); set(handles.avail_triplet,'string',new_triplet_str); curr_group=get(handles.groups,'value'); str_groups=get(handles.groups,'string'); SSA.groups{curr_group}=[SSA.groups{curr_group} str2num(str{val})]; str_groups{curr_group}=[str_groups{curr_group} ' ' str{val}]; set(handles.groups,'string',str_groups); if isempty(get(handles.avail_triplet,'string')) set([hObject handles.add_all handles.new_group],'enable','off'); end set(handles.remove,'enable','on'); % --- Executes on button press in add_all. function add_all_Callback(hObject, eventdata, handles) % hObject handle to add_all (see GCBO) global SSA str=get(handles.avail_triplet,'string'); if isempty(get(handles.groups,'string')) new_group_Callback(handles.new_group, eventdata, handles); end str_curr=get(handles.curr_group,'string'); str_curr={str_curr{:} str{:}}; set(handles.curr_group,'value',length(str_curr)); set(handles.curr_group,'string',str_curr); set(handles.avail_triplet,'value',0); set(handles.avail_triplet,'string',{}); curr_group=get(handles.groups,'value'); str_groups=get(handles.groups,'string'); for i=1:length(str) SSA.groups{curr_group}=[SSA.groups{curr_group} str2num(str{i})]; end for i=1:length(str) str_groups{curr_group}=[str_groups{curr_group} ' ' str{i}]; end set(handles.groups,'string',str_groups); if isempty(get(handles.avail_triplet,'string')) set([hObject handles.add handles.new_group],'enable','off'); end set(handles.remove,'enable','on'); % --- Executes on button press in new_group. function new_group_Callback(hObject, eventdata, handles) % hObject handle to new_group (see GCBO) global SSA set(handles.curr_group,'string',{}); str=get(handles.groups,'string'); groups_yet=length(str); if ~groups_yet str{groups_yet+1}=['group ' num2str(groups_yet+1) ': ']; set(handles.groups,'string',str); set(handles.groups,'value',groups_yet+1); SSA.groups{groups_yet+1}=[]; elseif ~isempty(SSA.groups{groups_yet}) str{groups_yet+1}=['group ' num2str(groups_yet+1) ': ']; set(handles.groups,'string',str); set(handles.groups,'value',groups_yet+1); SSA.groups{groups_yet+1}=[]; else set(handles.groups,'value',groups_yet); end set(handles.remove,'enable','off'); % --- Executes on button press in accept. function accept_Callback(hObject, eventdata, handles) % hObject handle to accept (see GCBO) global GSD_GLOBALS if get(handles.groups,'value') GSD_GLOBALS.en_dis.ssa_groups=1; else GSD_GLOBALS.en_dis.ssa_groups=0; end close(gcf); gui_en_dis; % --- Executes on button press in delete. function delete_Callback(hObject, eventdata, handles) % hObject handle to delete (see GCBO) global SSA GSD_GLOBALS close(gcf); SSA.groups={}; GSD_GLOBALS.en_dis.ssa_groups=0; gui_en_dis; % --- Executes on button press in remove. function remove_Callback(hObject, eventdata, handles) % hObject handle to remove (see GCBO) global SSA str_curr=get(handles.curr_group,'string'); if isempty(str_curr) return end val=get(handles.curr_group,'value'); r_triplet=str_curr{val}; str_triplets=get(handles.avail_triplet,'string'); str_triplets={str_triplets{:} str_curr{val}}; set(handles.avail_triplet,'value',length(str_triplets)); set(handles.avail_triplet,'string',str_triplets); k=1; new_curr_str={}; for i=1:length(str_curr) if i~=val new_curr_str{k}=str_curr{i}; k=k+1; end end set(handles.curr_group,'value',min([val length(new_curr_str)])); set(handles.curr_group,'string',new_curr_str); if isempty(new_curr_str) set(hObject,'enable','off'); end set([handles.add handles.add_all handles.new_group],'enable','on'); groups=get(handles.groups,'string'); val_groups=get(handles.groups,'value'); for i=1:length(SSA.groups{val_groups}) if SSA.groups{val_groups}(i)==str2num(r_triplet) SSA.groups{val_groups}(i)=[]; break end end str={}; new_gr={}; curr_g=1; for i=1:length(SSA.groups) if ~isempty(SSA.groups{i}) str{curr_g}=['group ' num2str(curr_g) ': ']; for j=1:length(SSA.groups{i}) str{curr_g}=[str{curr_g} ' ' num2str(SSA.groups{i}(j))]; end new_gr{curr_g}=SSA.groups{i}; curr_g=curr_g+1; end end SSA.groups=new_gr; set(handles.groups,'value',min([val_groups length(str)])); set(handles.groups,'string',str); groups_Callback(handles.groups, [], handles);