📄 mbclayout.m
字号:
function mbclayout
% This function will layout the gui controls. Eventually, this will be
% included in the complete function. Just have it now for simplicity.
% First get the user data from the root. See if anything is stored there.
% H.fig Handle to GUI figure window
%
% H.plots = [];
% H.allmodels = []; % this contains the structure of all models.
% H.bestmodel = []; % this contains the structure of the best model.
% H.bics = []; % BIC values.
% H.X = []; % Actual dataset - Need this for outputting CIDs.
%
% H.data Handle to popupmenu for data set to cluster. Default is X.
% {'X'} or Dimensionality-reduced data
% H.plotyp Handle to popupmenu for plots to visualize results
% {'BIC Curves','ReClus','Graphical EDA'}
% H.model Handle to popupmenu for model to output.
% {'Model 1';'Model 2';'Model 3';'Model 4';'Model 5';'Model 6';'Model 7';'Model 8';'Model 9'},...
% H.k Handle to edit box for number of clusters. Default is 2
% H.maxclus Handle to edit box for max number of clusters. Default is 10
% H.bmodtxt Handle to text box to display results - 'Best model: ...'
% H.nctxt Handle to text box to display results - 'Number of clusters:...'
ud = get(0,'userdata');
H.fig = figure('Tag','mbcgui',...
'position',[150 150 726 524],...
'resize','off',...
'toolbar','none',...
'menubar','none',...
'numbertitle','off',...
'name','Model-Based Clustering GUI',...
'CloseRequestFcn','mbcgui(''close'')');
if strcmp(version('-release'),'14')
set(0,'DefaultUicontrolFontname','Sans Serif');
end
H.plots = [];
H.allmodels = []; % this contains the structure of all models.
H.bestmodel = []; % this contains the structure of the best model.
H.bics = []; % BIC values.
H.X = [];
if ~isempty(ud)
% Then something is there already. Add necessary handles to the
% structure.
ud.guis = [ud.guis(:); H.fig];
else
% Set the usual stuff and save in root.
ud = userdata;
set(0,'userdata',ud)
end
% set up all of the frames first.
uicontrol(H.fig, 'style','frame',...
'position',[15 180 700 130]);
uicontrol(H.fig, 'style','frame',...
'position',[15 10 275 160]);
uicontrol(H.fig,'style','frame',...
'position',[300 10 415 160]);
%%%%%%% TEXT BOXES %%%%%%%%%%%%%%
% set up all of the text boxes
uicontrol(H.fig,'style','text',...
'position',[200 485 330 27],...
'fontweight','bold',...
'fontsize',14,...
'backgroundcolor',[.8 .8 .8],...
'string','Model-Based Clustering')
uicontrol(H.fig,'style','text',...
'position',[200 435 500 35],...
'horizontalalignment','left',...
'backgroundcolor',[.8 .8 .8],...
'string','This method estimates a finite mixture probability density function to cluster the data. The progress of the method can be viewed in the Command Window.')
%%%%%% AXES
% Set up some axes, so we can use a text box and the Latex interpreter.
H.ax = axes('position',[0.04 0.6 0.93 0.22]);
set(H.ax,'fontsize',8,'box','on');
strg = {'1: \Sigma_k = \lambda I : Spherical, Fixed volume, shape',...
'2: \Sigma_k = \lambda_k I : Spherical, Variable volume',...
'3: \Sigma_k = \lambda B : Diagonal, Fixed volume, shape',...
'4: \Sigma_k = \lambda B_k : Diagonal, Variable shape',...
'5: \Sigma_k = \lambda_k B_k : Diagonal, Variable volume, shape',...
'6: \Sigma_k = \lambda DAD'' : General, Fixed volume, shape, orientation',...
'7: \Sigma_k = \lambda D_k A D_k'' : General, Variable orientation',...
'8: \Sigma_k = \lambda D_k A_k D_k'' : General, Variable shape, orientation',...
'9: \Sigma_k = \Sigma_k : General, Variable volume, shape, orientation'};
x = [0.05*ones(1,5) 0.5*ones(1,4)];
y = [0.9 0.7 0.5 0.3 0.1 0.9 0.7 0.5 0.3];
text(x,y,strg,'fontsize',9)
axis off
% title text
uicontrol(H.fig,'style','text',...
'position',[40 280 170 20],...
'fontsize',10,...
'fontweight','bold',...
'horizontalalignment','left',...
'string','I. Create the Clusters')
uicontrol(H.fig,'style','text',...
'position',[40 130 205 20],...
'fontsize',10,...
'fontweight','bold',...
'horizontalalignment','left',...
'string','II. Visualize the Clusters')
uicontrol(H.fig,'style','text',...
'position',[330 130 230 20],...
'fontsize',10,...
'fontweight','bold',...
'horizontalalignment','left',...
'string','III. Output the Cluster IDs')
% Steps - text - Section I
uicontrol(H.fig,'style','text',...
'position',[40 215 100 40],...
'fontsize',9,...
'horizontalalignment','left',...
'string','1. Select data set to be clustered:')
uicontrol(H.fig,'style','text',...
'position',[185 215 100 40],...
'fontsize',9,...
'horizontalalignment','left',...
'string','2. Max number of clusters:')
uicontrol(H.fig,'style','text',...
'position',[305 215 100 40],...
'fontsize',9,...
'horizontalalignment','left',...
'string','3. Push to cluster:')
uicontrol(H.fig,'style','text',...
'position',[440 270 100 30],...
'fontsize',9,...
'fontweight','bold',...
'horizontalalignment','left',...
'string','RESULTS:')
H.bmodtxt = uicontrol(H.fig,'style','text',...
'position',[440 240 100 30],...
'fontsize',9,...
'horizontalalignment','left',...
'string','Best model:');
H.nctxt = uicontrol(H.fig,'style','text',...
'position',[440 205 150 30],...
'fontsize',9,...
'horizontalalignment','left',...
'string','Number of clusters:');
% Text - Section II:
uicontrol(H.fig,'style','text',...
'position',[40 90 182 30],...
'fontsize',9,...
'horizontalalignment','left',...
'string','Select plot type:')
uicontrol(H.fig,'style','text',...
'position',[175 90 100 30],...
'fontsize',9,...
'horizontalalignment','left',...
'string','Push to create plot:')
% Text - Section III:
uicontrol(H.fig,'style','text',...
'position',[330 90 100 30],...
'fontsize',9,...
'horizontalalignment','left',...
'string','1. Number of clusters:')
uicontrol(H.fig,'style','text',...
'position',[450 90 150 30],...
'fontsize',9,...
'horizontalalignment','left',...
'string','2. Choose model:')
uicontrol(H.fig,'style','text',...
'position',[590 90 110 30],...
'fontsize',9,...
'horizontalalignment','left',...
'string','3. Push to output IDs:')
%%%%%%% BUTTONS %%%%%%%%%%%%%%%%%%%%
uicontrol(H.fig,'style','pushbutton',...
'position',[14 496 170 23],...
'string','LOAD DATA',...
'tooltipstring','This will bring up the Load Data GUI',...
'callback','loadgui')
uicontrol(H.fig,'style','pushbutton',...
'position',[14 468 170 23],...
'string','TRANSFORM',...
'tooltipstring','This will bring up the Transform Data GUI.',...
'callback','transformgui')
uicontrol(H.fig,'style','pushbutton',...
'position',[14 439 170 23],...
'string','DIMENSIONALITY REDUCTION',...
'tooltipstring','This will bring up the Dimensionality Reduction GUI.',...
'callback','dimredgui')
%%%%%%%%%%%%%%%%%%%%%%
uicontrol(H.fig,'style','pushbutton',...
'position',[300 195 100 25],...
'string','DO CLUSTERING',...
'tooltipstring','This will perform the clustering procedure.',...
'callback','mbcgui(''doclus'')')
uicontrol(H.fig,'style','pushbutton',...
'position',[175 55 75 22],...
'string','DO PLOT',...
'tooltipstring','This will plot the data.',...
'callback','mbcgui(''doplot'')')
uicontrol(H.fig,'style','pushbutton',...
'position',[575 45 130 35],...
'string','OUTPUT CLUSTER IDs',...
'tooltipstring','This will save an n-dimensional vector of cluster IDs to the workspace.',...
'callback','mbcgui(''cidsout'')')
% Close button
uicontrol(H.fig,'style','pushbutton',...
'position',[620 485 66 25],...
'string','CLOSE',...
'callback','mbcgui(''close'')',...
'tooltipstring','Push this button to close the GUI window.')
%%%%%%% POPUPMENUS %%%%%%%%%%%%%%%%%%%%%%%
H.data = uicontrol('style','popupmenu',...
'String',ud.dimred,...
'position',[45 195 75 22],...
'backgroundcolor','white');
H.plotyp = uicontrol('style','popupmenu',...
'String',{'BIC Curves','ReClus','Graphical EDA'},...
'position',[45 55 100 22],...
'backgroundcolor','white');
H.model = uicontrol('style','popupmenu',...
'String',{'Model 1';'Model 2';'Model 3';'Model 4';'Model 5';'Model 6';'Model 7';'Model 8';'Model 9'},...
'position',[450 55 100 22],...
'backgroundcolor','white',...
'tooltipstring','The cluster IDs will be based on this model.');
%%%%%% EDIT BOXES %%%%%%%%%%%%%%%%%%%%%%
H.k = uicontrol('style','edit',...
'string','2',...
'position',[335 55 50 22],...
'backgroundcolor','white',...
'tooltipstring','These are the number of clusters that will be used to output cluster IDs.');
H.maxclus = uicontrol('style','edit',...
'string','10',...
'position',[185 195 50 22],...
'backgroundcolor','white',...
'tooltipstring','These are the maximum number of clusters.');
% Save Handles for THIS GUI in the UserData for this figure.
set(gcf,'userdata',H)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -