📄 mdslayout.m
字号:
function mdslayout
% 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 of GUI figure window
% H.plots Handles for plot windows opened with this GUI.
% H.cmdsdim Handle to edit box specifying number of dimensions in CMDS. default is 2
% H.mdsdim Handle to edit box specifying number of dimensions (or range) for doing MDS. Default is 1 to 10.
% H.cmdsdist Handle to popupmenu for specifying the distance in CMDS
% H.mdsdist Handle to popupmenu for specifying the distance in MDS
% H.scaletype Handle to popupmenu for Metric or Nonmetric MDS
% H.starttype Handle to popupmenu for starting point for Metric/nonmetric MDS
ud = get(0,'userdata');
H.fig = figure('Tag','mdsgui',...
'position',[150 150 726 524],...
'resize','off',...
'toolbar','none',...
'menubar','none',...
'numbertitle','off',...
'name','Multi-Dimensional Scaling GUI',...
'CloseRequestFcn','mdsgui(''close'')');
if strcmp(version('-release'),'14')
set(0,'DefaultUicontrolFontname','Sans Serif');
end
% Keep track of GUI plots in this array. So, we can close when the gui is
% closed.
H.plots = [];
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
%%%%%%% FRAMES %%%%%%%%%%%%%%%
% set up all of the frames first.
uicontrol(H.fig, 'style','frame',...
'position',[25 295 686 150]);
uicontrol(H.fig, 'style','frame',...
'position',[25 20 686 260]);
%%%%%%% TEXT BOXES %%%%%%%%%%%%%%
% set up all of the text boxes
uicontrol(H.fig,'style','text',...
'position',[170 485 330 27],...
'fontweight','bold',...
'fontsize',14,...
'backgroundcolor',[.8 .8 .8],...
'string','Multi-Dimensional Scaling')
% Title boxes
uicontrol(H.fig,'style','text',...
'position',[40 405 95 34],...
'fontweight','bold',...
'fontsize',10,...
'horizontalalignment','left',...
'string','Classical MDS')
uicontrol(H.fig,'style','text',...
'position',[40 235 110 34],...
'fontweight','bold',...
'fontsize',10,...
'horizontalalignment','left',...
'string','Metric MDS')
% Instruction text boxes:
uicontrol(H.fig,'style','text',...
'position',[150 408 540 30],...
'horizontalalignment','left',...
'string','CMDS is a deterministic method based on eigenvalue decomposition. The scaling produces a scree plot. Use the elbow in the curve to specify the number of dimensions.')
uicontrol(H.fig,'style','text',...
'position',[160 235 540 30],...
'horizontalalignment','left',...
'string','Different random starts can give different configurations. This uses the SMACOF algorithm.')
uicontrol(H.fig,'style','text',...
'position',[115 450 500 35],...
'horizontalalignment','left',...
'backgroundcolor',[.8 .8 .8],...
'string','Use these methods to find d-dimensional representations that preserve the original interpoint distances. The LOAD DATA button can be used to load an interpoint distance matrix, instead of the data matrix.')
% Steps - text in frame 1
uicontrol(H.fig,'style','text',...
'position',[40 370 200 20],...
'fontsize',9,...
'horizontalalignment','left',...
'string','0. Calculate distances, if necessary:')
uicontrol(H.fig,'style','text',...
'position',[40 340 150 20],...
'fontsize',9,...
'horizontalalignment','left',...
'string','1. Do the scaling:')
uicontrol(H.fig,'style','text',...
'position',[160 340 2350 20],...
'fontsize',9,...
'horizontalalignment','left',...
'string','2. Value of d for output to workspace:')
uicontrol(H.fig,'style','text',...
'position',[410 340 200 20],...
'fontsize',9,...
'horizontalalignment','left',...
'string','Visually explore the data:')
% Steps - text in frame 2
% uicontrol(H.fig,'style','text',...
% 'position',[40 205 170 20],...
% 'FontName', 'FixedWidth',...
% 'fontsize',9,...
% 'horizontalalignment','left',...
% 'string','0. Calculate distances:')
uicontrol(H.fig,'style','text',...
'position',[40 160 150 32],...
'fontsize',9,...
'horizontalalignment','left',...
'string','0. Calculate distances, if necessary:')
uicontrol(H.fig,'style','text',...
'position',[200 160 128 32],...
'fontsize',9,...
'horizontalalignment','left',...
'string','1. Starting configuration:')
uicontrol(H.fig,'style','text',...
'position',[370 160 225 32],...
'fontsize',9,...
'horizontalalignment','left',...
'string','2. Enter a value for d:')
uicontrol(H.fig,'style','text',...
'position',[40 80 110 20],...
'fontsize',9,...
'horizontalalignment','left',...
'string','3. Do the scaling:')
uicontrol(H.fig,'style','text',...
'position',[410 80 200 20],...
'fontsize',9,...
'horizontalalignment','left',...
'string','Visually explore the data:')
% uicontrol(H.fig,'style','text',...
% 'position',[285 80 200 20],...
% 'fontsize',9,...
% 'horizontalalignment','left',...
% 'string','Display Shephard plot (NMDS only):')
%%%%%%% BUTTONS %%%%%%%%%%%%%%%%%%%%
uicontrol(H.fig,'style','pushbutton',...
'position',[14 491 88 23],...
'string','LOAD DATA',...
'fontsize',9,...
'tooltipstring','This will bring up the Load Data GUI',...
'callback','loadgui')
uicontrol(H.fig,'style','pushbutton',...
'position',[14 463 88 23],...
'string','TRANSFORM',...
'fontsize',9,...
'tooltipstring','This will bring up the Transform Data GUI.',...
'callback','transformgui')
%%%%%%%%%%%%%%%%%% in frames
uicontrol(H.fig,'style','pushbutton',...
'position',[560 310 130 25],...
'string','OUTPUT DATA',...
'fontsize',9,...
'tooltipstring','This will save the data from Classical MDS to the workspace, using the number of dimensions in the edit box.',...
'callback','mdsgui(''cmdsout'')')
uicontrol(H.fig,'style','pushbutton',...
'position',[410 310 130 25],...
'string','GRAPHICAL EDA GUI',...
'fontsize',9,...
'tooltipstring','This will open the Graphical EDA GUI.',...
'callback','mdsgui(''geda'',''CMDS'')')
uicontrol(H.fig,'style','pushbutton',...
'position',[45 310 90 25],...
'string','DO SCALING',...
'fontsize',9,...
'tooltipstring','This will do Classical MDS and display a scree plot.',...
'callback','mdsgui(''docmds'')')
%%%%%%%%%%%%%%%%%%%%%%%
uicontrol(H.fig,'style','pushbutton',...
'position',[560 50 130 25],...
'string','OUTPUT DATA',...
'fontsize',9,...
'tooltipstring','This will save the projected data to the workspace.',...
'callback','mdsgui(''mdsout'')')
uicontrol(H.fig,'style','pushbutton',...
'position',[410 50 130 25],...
'string','GRAPHICAL EDA GUI',...
'fontsize',9,...
'tooltipstring','This will open the Graphical EDA GUI.',...
'callback','mdsgui(''geda'',''MDS'')')
% uicontrol(H.fig,'style','pushbutton',...
% 'position',[310 50 115 22],...
% 'string','DISPLAY PLOT',...
% 'tooltipstring','This will display a Shephard plot.',...
% 'callback','')
uicontrol(H.fig,'style','pushbutton',...
'position',[40 50 90 25],...
'string','DO SCALING',...
'fontsize',9,...
'tooltipstring','This will do the scaling.',...
'callback','mdsgui(''domds'')')
% Close button
uicontrol(H.fig,'style','pushbutton',...
'position',[620 485 66 25],...
'string','CLOSE',...
'callback','mdsgui(''close'')',...
'fontsize',9,...
'tooltipstring','Push this button to close the GUI window.')
%%%%%% EDIT BOXES %%%%%%%%%%%%%%%%%%%%%%
% First frame
H.cmdsdim = uicontrol('style','edit',...
'string','2',...
'position',[220 310 38 20],...
'backgroundcolor','white',...
'fontsize',9,...
'tooltipstring','The value you enter here will be used in Graphical EDA and as output to the workspace.');
% % Second Frame
H.mdsdim = uicontrol('style','edit',...
'string','2',...
'position',[390 130 75 22],...
'fontsize',9,...
'backgroundcolor','white');
%%%%%%%%% POPUPMENU %%%%%%%%%%%%%%%%%
H.cmdsdist = uicontrol('style','popupmenu',...
'position',[250 370 100 22],...
'backgroundcolor','white',...
'String',{'euclidean';'seuclidean';'cityblock';'mahalanobis';'minkowski'});
H.mdsdist = uicontrol('style','popupmenu',...
'position',[40 130 100 22],...
'backgroundcolor','white',...
'String',{'euclidean';'seuclidean';'cityblock';'mahalanobis';'minkowski'});
% H.scaletype = uicontrol('style','popupmenu',...
% 'position',[40 130 100 22],...
% 'backgroundcolor','white',...
% 'String',{'Metric MDS','Nonmetric MDS'});
H.starttype = uicontrol('style','popupmenu',...
'position',[200 130 110 22],...
'backgroundcolor','white',...
'String',{'Classical MDS','Random'});
% 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 + -