📄 loadgui.m
字号:
end
if n ~= length(data)
errordlg('The number of case labels must match the number of data points - n.')
return
end
% Replace the case label values in the User Data structure.
ud.caselab = data;
set(0,'userdata',ud)
else
return
end
% Check to see if the brush/link GUI is open. If so, update the strings for
% the case label list box.
Hbgui = findobj('tag','brushgui');
if ~isempty(Hbgui)
% then the gui is open.
H = get(Hbgui,'userdata');
set(H.listcase,'string',ud.caselab)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function caselabws(w)
% Load the data from the workspace.
if isempty(w)
errordlg('You do not have any variables in the workspace.')
return
end
[choice,ok] = listdlg('PromptString','Select a variable:',...
'SelectionMode','single',...
'ListString',w);
if ok ~= 0
% then user selected something
str = ['ud = get(0,''userdata'');' 'ud.tmp = ' w{choice} ';' 'set(0,''userdata'',ud)'];
evalin('base',str)
ud = get(0,'userdata');
% Do an error check. The length of the caselabel vector.
[n,p] = size(ud.X);
[nc, np] = size(ud.tmp);
if ~isnumeric(ud.tmp) & ~iscell(ud.tmp)
% First it has to be numeric or a cell array.
errordlg('The vector must be of type double or a cell array of strings.')
return
end
if iscell(ud.tmp) & ~ischar(ud.tmp{1})
errordlg('If it is a cell array, then it must be a cell array of strings.')
return
end % checking to see if it is a cell array of strings
if nc ~= 1 & np ~= 1
errordlg('The data used for case labels must be a vector.')
return
end
if n ~= length(ud.tmp)
errordlg('The number of case labels must match the number of data points - n.')
return
end
ud.caselab = ud.tmp;
set(0,'userdata',ud)
else
return
end
% Check to see if the brush/link GUI is open. If so, update the strings for
% the case label list box.
Hbgui = findobj('tag','brushgui');
if ~isempty(Hbgui)
% then the gui is open.
H = get(Hbgui,'userdata');
set(H.listcase,'string',ud.caselab)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varlabfile
% Load up labels for variable names - OPTIONAL
% assume this is a text file only with one variable. If user wants to
% import a .mat file, then they should just load in the workspace and load
% that way.
ud = get(0,'userdata');
[filename, pathname] = uigetfile({'*.txt';'*.*'}, 'Pick a file');
if filename ~= 0
% user did not press cancel.
data = load([pathname filename]);
% check to see if a mat file
if isstruct(data)
errordlg('You are trying to load a .mat file. Load the .mat file into the workspace using the Command Line. Then use the GUI to load from the workspace.','Loading Error')
return
end
% Do an error check. The length of the caselabel vector.
[n,p] = size(ud.X);
[nc, np] = size(data);
if nc ~= 1 & np ~= 1
errordlg('The data used for variable labels must be a vector.')
return
end
if p ~= length(data)
errordlg('The number of variable labels must match the number of variables p.')
return
end
% Replace the case label values in the User Data structure.
ud.varlab = data;
set(0,'userdata',ud)
else
return
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
function varlabws(w)
% Load the data from the workspace.
if isempty(w)
errordlg('You do not have any variables in the workspace.')
return
end
[choice,ok] = listdlg('PromptString','Select a variable:',...
'SelectionMode','single',...
'ListString',w);
if ok ~= 0
% then user selected something
str = ['ud = get(0,''userdata'');' 'ud.tmp = ' w{choice} ';' 'set(0,''userdata'',ud)'];
evalin('base',str)
ud = get(0,'userdata');
% Do an error check. The length of the caselabel vector.
[n,p] = size(ud.X);
[nc, np] = size(ud.tmp);
if ~isnumeric(ud.tmp) & ~iscell(ud.tmp)
% First it has to be numeric or a cell array.
errordlg('The vector must be of type double or a cell array of strings.')
return
end
if iscell(ud.tmp) & ~ischar(ud.tmp{1})
errordlg('If it is a cell array, then it must be a cell array of strings.')
return
end % checking to see if it is a cell array of strings
if nc ~= 1 & np ~= 1
errordlg('The data used for variable labels must be a vector.')
return
end
if p ~= length(ud.tmp)
errordlg('The number of variable labels must match the number of variables p.')
return
end
ud.varlab = ud.tmp;
set(0,'userdata',ud)
else
return
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function classlabfile
% Load up labels for observations - OPTIONAL
% assume this is a text file only with one variable. If user wants to
% import a .mat file, then they should just load in the workspace and load
% that way.
ud = get(0,'userdata');
[filename, pathname] = uigetfile({'*.txt';'*.*'}, 'Pick a file');
if filename ~= 0
% user did not press cancel.
data = load([pathname filename]);
% check to see if a mat file
if isstruct(data)
errordlg('You are trying to load a .mat file. Load the .mat file into the workspace using the Command Line. Then use the GUI to load from the workspace.','Loading Error')
return
end
% Do an error check. The length of the caselabel vector.
[n,p] = size(ud.X);
[nc, np] = size(data);
if nc ~= 1 & np ~= 1
errordlg('The data used for class/group labels must be a vector.')
return
end
if n ~= length(data)
errordlg('The number of class/group labels must match the number of data points - n.')
return
end
% Replace the case label values in the User Data structure.
ud.classlab = data;
set(0,'userdata',ud)
else
return
end
% Check to see if the brush/link GUI is open. If so, update the strings for
% the case label list box.
Hbgui = findobj('tag','brushgui');
if ~isempty(Hbgui)
% then the gui is open.
H = get(Hbgui,'userdata');
set(H.listgroup,'string',unique(ud.classlab))
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function classlabws(w)
% Load the data from the workspace.
if isempty(w)
errordlg('You do not have any variables in the workspace.')
return
end
[choice,ok] = listdlg('PromptString','Select a variable:',...
'SelectionMode','single',...
'ListString',w);
if ok ~= 0
% then user selected something
str = ['ud = get(0,''userdata'');' 'ud.tmp = ' w{choice} ';' 'set(0,''userdata'',ud)'];
evalin('base',str)
ud = get(0,'userdata');
% Do an error check. The length of the caselabel vector.
[n,p] = size(ud.X);
[nc, np] = size(ud.tmp);
if ~isnumeric(ud.tmp) & ~iscell(ud.tmp)
% First it has to be numeric or a cell array.
errordlg('The vector must be of type double or a cell array of strings.')
return
end
if iscell(ud.tmp) & ~ischar(ud.tmp{1})
errordlg('If it is a cell array, then it must be a cell array of strings.')
return
end % checking to see if it is a cell array of strings
if nc ~= 1 & np ~= 1
errordlg('The data used for class/group labels must be a vector.')
return
end
if n ~= length(ud.tmp)
errordlg('The number of class/group labels must match the number of data points - n.')
return
end
ud.classlab = ud.tmp;
set(0,'userdata',ud)
else
return
end
% Check to see if the brush/link GUI is open. If so, update the strings for
% the case label list box.
Hbgui = findobj('tag','brushgui');
if ~isempty(Hbgui)
% then the gui is open.
H = get(Hbgui,'userdata');
set(H.listgroup,'string',unique(ud.classlab))
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -