?? findcluster.m
字號:
if abs(obj_fcn(i) - obj_fcn(i-1)) < min_impro, break; end,
end
end
%============
%% maxU = max(U);
%% color=['c', 'g', 'b', 'r', 'm'];
%% for i = 1:cluster_n,
%% index = find(U(i, :) == maxU);
%% cluster = param.data(index', :);
%% if isempty(cluster), cluster = [nan nan]; end
% hold on
%% line('xdata', cluster(:, 1), ...
%% 'ydata', cluster(:, 2),... % 'zdata', cluster(:, 3),...
%% 'linestyle', 'none', 'color', color(mod(i, 5)+1),...
%% 'marker', '*');
%% end
drawnow
%=====================
end
set(stopHndl, 'String', 'Start');
param.center=center;
if ~isempty(center)
saveHndl = findobj(gcf, 'Tag', 'save');
set(saveHndl, 'Enable', 'on');
end
set(gcbf, 'UserData', param);
findcluster #dispdim
end %if stopHndl
case 'open',
% open an existing file
param=get(gcbf,'UserData');
[fname, fpath]=uigetfile('*.dat');
if isstr(fname)&isstr(fpath)
% cd(fpath(1:(length(fpath)-1)));
filename=[fpath fname];
localloadfile(filename, param);
end
case 'save',
param= get(gcf, 'Userdata');
[fname, fpath]=uiputfile('*.dat', 'Save As');
center = param.center;
if isstr(fname)&isstr(fpath)
save([fpath fname], 'center', '-ascii', '-double');
end
case '#mousedownstr'
patchHndl=gco;
showStr=get(patchHndl, 'Tag');
showPosx = get(patchHndl, 'XData');
showPosy = get(patchHndl, 'YData');
textHndl=findobj(gcf, 'Tag', 'strcparam');
a=100;
set(textHndl,'String', 'test', 'Position', [showPosx(1) showPosy(1) .2 .080], 'Visible', 'on');
case 'info',
helpwin(mfilename)
end; % if strcmp(action, ...
% End of function makeshow
%===================================
function LocalButtonControl
medHndl=findobj(gcf, 'Tag', 'method');
clustnumHndl=findobj(gcf, 'Tag', 'setclstrnum');
infuHndl=findobj(gcf, 'Tag', 'influence');
squaHndl=findobj(gcf, 'Tag', 'squash');
accpHndl=findobj(gcf, 'Tag', 'accept');
rejcHndl=findobj(gcf, 'Tag', 'reject');
expoHndl=findobj(gcf, 'Tag', 'influence');
maxiHndl=findobj(gcf, 'Tag', 'squash');
miniHndl=findobj(gcf, 'Tag', 'accept');
numHndl=findobj(gcf, 'Tag', 'reject');
sbtrLabelHndl=findobj(gcf, 'Tag', 'sbtrparam');
n=get(medHndl, 'value');
if n==1
set(sbtrLabelHndl, 'Visible', 'on');
set(infuHndl, 'Visible', 'on');
set(squaHndl, 'Visible', 'on');
set(accpHndl, 'Visible', 'on');
set(rejcHndl, 'Visible', 'on');
set(clustnumHndl, 'Visible', 'off');
else
set(sbtrLabelHndl, 'Visible', 'off');
set(infuHndl, 'Visible', 'off');
set(squaHndl, 'Visible', 'off');
set(accpHndl, 'Visible', 'off');
set(rejcHndl, 'Visible', 'off');
set(clustnumHndl, 'Visible', 'on');
end
%==================================================
function uiHandle=LocalBuildUi(uiPos, uiStyle, uiCallback, promptStr, uiTag)
% build editable text
uiHandle=uicontrol( ...
'Style',uiStyle, ...
'HorizontalAlignment','left', ...
'Units','normalized', ...
'Max',20, ...
'BackgroundColor',[1 1 1], ...
'Position',uiPos, ...
'Callback',uiCallback, ...
'Tag', uiTag, ...
'String',promptStr);
%==================================================
function frmHandle=LocalBuildFrmTxt(frmPos, txtStr, uiStyle, txtTag)
% build frame and label
frmHandle=uicontrol( ...
'Style', uiStyle, ...
'Units','normalized', ...
'Position',frmPos, ...
'BackgroundColor',[0.50 0.50 0.50], ...
'ForegroundColor',[1 1 1], ... %generates an edge
'String', txtStr, ...
'Tag', txtTag);
%==================================================
function btHandle=LocalBuildBtns(thisstyle, btnNumber, labelStr, callbackStr, uiTag)
% build buttons or check boxes so they easily aline on the right
labelColor=[0.8 0.8 0.8];
top=0.95;
left=0.80;
btnWid=0.15;
btnHt=0.05;
bottom=0.05;
% Spacing between the button and the next command's label
spacing=0.01;
if strcmp(thisstyle, 'edit')
% btnHt =.05;
end
yPos=top-(btnNumber-1)*(btnHt+spacing);
if strcmp(labelStr, 'Close')==1
yPos= bottom;
elseif strcmp(labelStr, 'Info')==1
yPos= bottom+btnHt+spacing;
else
yPos=top-(btnNumber-1)*(btnHt+spacing)-btnHt;
end
%button information
btnPos=[left yPos btnWid btnHt];
btHandle=uicontrol( ...
'Style',thisstyle, ...
'Units','normalized', ...
'Position',btnPos, ...
'String',labelStr, ...
'Tag', uiTag, ...
'Callback',callbackStr);
if strcmp(thisstyle, 'text')
set(btHandle, 'BackgroundColor', [.5 .5 .5], 'ForeGroundColor', [1 1 1]);
end
function LocalPlotdata(dispList)
param=get(gcf, 'Userdata');
param.dispList = dispList;
axesHndl=findobj(gcf, 'Tag', 'mainaxes');
axes(axesHndl);
% cla
data=param.data;
plotmarker = 'o';
plotcolor='red';
center=param.center;
plotmarker1='.';
plotcolor1='black';
if param.dataDim > 1
ydim=2;
else
ydim=1;
end
if ~isempty(data)
dataplotH = line(data(:, dispList(1)), data(:, dispList(2)),... %data(:, dispList(3)),...
'color', plotcolor, ...
'LineStyle', 'none',...
'Marker', plotmarker,...
'clipping', 'off');
end
if ~isempty(center)
centerplotH = line(center(:, dispList(1)), center(:, dispList(2)),... %center(:, dispList(3)),...
'color', plotcolor1, ...
'LineStyle', 'none', 'Marker', plotmarker1,...
'MarkerSize', 16,...
'ButtonDownFcn', 'findcluster #mousedownstr',...
'clipping', 'off', 'erase', 'none');
param.centerplotH=centerplotH;
set(gcbf, 'Userdata', param);
end
drawnow
function localloadfile(filename, param)
load(filename);
slashindex=find(filename==filesep);
if ~isempty(slashindex)
strtindex=max(slashindex)+1;
else
strtindex=1;
end
dotIndex=find(filename=='.');
varname=filename(strtindex:dotIndex-1);
data=eval(varname);
param.data=data;
param.dataDim = size(data, 2);
param.center=[];
if param.dataDim>1
dispList = [1 2]; %[1 2 2];
dimHndlx=findobj(gcf, 'Tag', 'dimX');
dimHndly=findobj(gcf, 'Tag', 'dimY');
% dimHndlz=findobj(gcf, 'Tag', 'dimZ');
for i=1:param.dataDim
dispstr{i}=['data_' num2str(i)];
end
set(dimHndlx, 'String', dispstr);
set(dimHndly, 'String', dispstr);
% set(dimHndlz, 'String', dispstr);
% if param.dataDim > 2
% dispList(3)=3;
% set(dimHndlz, 'Value', 3);
% end
set(dimHndly, 'Value', 2);
else
dispList = [1 1]; %[1 1 1];
end
if ~isempty(data)
startHndl = findobj(gcf, 'Tag', 'start');
set(startHndl, 'Enable', 'on');
end
if isempty(param.center)
saveHndl = findobj(gcf, 'Tag', 'save');
set(saveHndl, 'Enable', 'off');
end
param.dispList = dispList;
set(gcf, 'Userdata', param);
LocalPlotdata(dispList);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -