⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 som_show_add.m

📁 此源码提供了ssvm的完整的matlab源代码
💻 M
📖 第 1 页 / 共 4 页
字号:
	       mode_ '''.']);  else     Property=setfield(Property,identifier,value);  endend% set default subplotif isempty(Property.subplot)  % search the subplot number for current axis  value=find(gca==handles);      if isempty(value) | value>length(handles)     error('SubPlot default value setting: current axis is not in the figure!');  else    Property.subplot=value;  endend  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Main switch: select the right subfunction %%%%%%%%%%%%%%%%%%%switch mode case 'hit'  h_=hit(D, lattice, msize, Property);   case 'mhit'  h_=mhit(D, lattice, msize, Property);   case 'label'  h_=label(D, lattice, msize, Property); case 'traj'  h_=traj(D, lattice, msize, Property); case 'comet'  %error('Not yet implemented.');   h_=comet(D, lattice, msize, Property); otherwise  error('Whoops! Internal error: unknown mode!');end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Build output if necessary %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%if nargout>0  h=h_;end%%%% SUBFUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function h_=hit(Hits, lattice, msize, Property);  % number of map unitsmunits=prod(msize);% subplotsp=Property.subplot;handles=Property.handles;% Set default markerif isempty(Property.marker),  if strcmp(Property.text,'on')    Property.marker='none';  else    Property.marker='lattice';  endend% Set default markersizeif isempty(Property.markersize)  if strcmp(Property.marker,'none'),    warning('MarkerSize is not meaningful since Marker is set to ''none''.');  elseif strcmp(Property.marker,'lattice'),    Property.markersize=1; % normalized size  else    Property.markersize=12; % points  endend% Set default colorsif ~isempty(Property.markercolor),  if strcmp(Property.marker,'none')    warning('MarkerColor is not used since Marker is set to ''none''.');    Property.markercolor=[]; % not used  else    ; % ok  endelseif any(strcmp(Property.marker,{'+','*','.','x'})),  % these don't use fill color: 'none' will cause default  % edgecolor to be 'k'.  Property.markercolor='none'; else  Property.markercolor='k';endif ~isempty(Property.edgecolor),  if strcmp(Property.marker,'none')    warning(['EdgeColor is not used since Marker is set to' ...	     ' ''none''.']);  else    ; %ok   endelseif ~strcmp(Property.markercolor,'none'),  Property.edgecolor='none';else  Property.edgecolor='k';end% Set default textif isempty(Property.text),  Property.text='off';end% Set default textsizeif isempty(Property.textsize)  Property.textsize=10;elseif strcmp(Property.text,'off')    warning('TextSize not used as hits are not set to be shown as numbers.');end% Set default textcolorif isempty(Property.textcolor)  Property.textcolor='w';elseif strcmp(Property.text,'off')    warning('TextColor not used as hits are not set to be shown as numbers.');end%% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%h_=[];          % this variable is for collecting the object handles% Select the drawing mode if ~strcmp(Property.marker,'none')     %%%%% Draw spots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    % unit coordinates   coord=som_vis_coords(lattice,msize);    % Calculate the size of the spots  mx=max(Hits);    if mx==0,    % nothing to draw!    h_=[];     return  else    Size=sqrt(Hits./mx);        end  % coordinates for non-zero hits (only those are drawn)  coord=coord(Size~=0,:);  Size=Size(Size~=0);  N=size(Size,1);    % som_cplane can't draw one unit with arbitrary  % coordinates as it its mixed with msize:  if size(coord,1)==1 & strcmp(Property.marker,'lattice'),    Size=[Size;Size];    coord=[coord;coord];  end    for i=1:length(p),    % Set axes    axes(handles(p(i)));    % Get hold state and caxis    memhold=ishold; cax=caxis;         hold on;        switch Property.marker     case 'lattice'      h_(i,1)=som_cplane(lattice, coord, Property.markercolor, ...			 Property.markersize*Size);     otherwise        [S,m]=som_grid(lattice, [N 1],...		     'Coord',coord, ...		     'Line','none',...		     'Marker',Property.marker,...		     'MarkerColor',Property.markercolor,...		     'MarkerSize', Size*Property.markersize);      h_=[h_;m(:)];    end        % Restore hold state    if ~memhold               hold off;    end  end    % Set edgecolor  if strcmp(Property.marker,'lattice')    set(h_,'edgecolor',Property.edgecolor);  else    set(h_,'markeredgecolor',Property.edgecolor);  endend  if strcmp(Property.text,'on'),  %%%%% Draw numbers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      % Do numbers  Hits=reshape(Hits,[munits 1]);  labels=cell([munits 1]);  for i=1:length(Hits)    if Hits(i)              % zero hit won't be shown      labels(i)={num2str(Hits(i))};    end  end  for i=1:length(p),    axes(handles(p(i)));    % Set axes    memhold=ishold;         % Get hold state    hold on;    [S,m,l,t]=som_grid(lattice, msize, ...		       'Line','none',...		       'Marker','none', ...		       'Label',labels, ...		       'LabelColor', Property.textcolor, ...		       'LabelSize', Property.textsize);    % Get handles    h_=[h_;t(:)];        % Restore hold state and caxis    if ~memhold           hold off;    end    caxis(cax);  end  % Remove zero object handles (missing objects)  h_=setdiff(h_,0);end%% Set object tags (for som_show_clear) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%set(h_,'Tag','Hit')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function h_=mhit(Hits, lattice, msize, Property);  % number of map unitsmunits=prod(msize);% subplotsp=Property.subplot;handles=Property.handles;% Set default markerif isempty(Property.marker),  Property.marker=lattice;end% variable 'mode' indicates which kind of markers are used:if iscell(Property.marker),  mode='marker';elseif vis_valuetype(Property.marker,{'markerstyle'}),  mode='marker';elseif strcmp(Property.marker,'pie'),  mode='pie';else  mode='lattice';end% Set default size scalingif isempty(Property.sizefactor)  Property.sizefactor='separate';end% Set default markersize if isempty(Property.markersize)  if any(strcmp(mode,{'lattice','pie'})),    Property.markersize=1; % normalized  else    Property.markersize=12;  % points  endend% Set default colorsif isempty(Property.markercolor),  Property.markercolor=hsv(size(Hits,2));endif isempty(Property.edgecolor),  if vis_valuetype(Property.markercolor,{'none'}),    Property.edgecolor='k';  else    Property.edgecolor='none';  endend% Set default shiftif isempty(Property.shift)  Property.shift=0;end%% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%h_=[];          % this variable is for collecting the object handlesswitch mode  case {'marker','lattice'}   % Number of hits histograms   n_Hits=size(Hits,2);   % Calculate the size of the spots      if strcmp(Property.sizefactor,'common')     mx=max(max(Hits));     if mx==0 % nothing to draw!       h_=[]; return     end     spotSize=sqrt(Hits./mx);   else     mx=repmat(max(Hits),munits,1);     mx(mx==0)=1; % Prevent division by zero     spotSize=sqrt(Hits./mx);   end      %%% Make spotSize      %reshape Size to a vector [spotSizeforHist(:,1); spotSizeforHist(:,2);...]   spotSize=spotSize(:);      % indices for non-zero hits (only those are drawn)   notZero=find(spotSize ~= 0);      % Drop zeros away from spotSize   spotSize=spotSize(notZero);      % Order spots so that bigger will be drawn first, so that they    % won't hide smaller ones   [dummy, sizeOrder]=sort(spotSize); sizeOrder=sizeOrder(end:-1:1);   spotSize=spotSize(sizeOrder);      %%% Make unit coordinates    coord=som_vis_coords(lattice,msize);      move=repmat(linspace(-.1,.1,n_Hits),size(coord,1),1)*Property.shift;   move=repmat(move(:),1,2);      % do n_Hits copies of unit coordinates so that they match spotSize   coord=repmat(coord,n_Hits,1)+move;      % Drop zeros away from coords and order   coord=coord(notZero,:);   coord=coord(sizeOrder,:);      %%% Make unit colors      if vis_valuetype(Property.markercolor,{'nx3'}),     % If multiple colors Copy unit colors so that they match spotSize     color=Property.markercolor(reshape(repmat([1:n_Hits]',1,munits)',...					munits*n_Hits,1),:);     % drop zeros away & order     color=color(notZero,:);     color=color(sizeOrder,:);   else     % only on color     color=Property.markercolor;   end      %%% Make unit markers      if iscell(Property.marker),     %marker shows class:      marker=char(Property.marker);     marker=marker(reshape(repmat([1:n_Hits]',1,munits)',...			   munits*n_Hits,1),:);     % Drop zeros, order & make to cell array (for som_grid)     marker=marker(notZero,:);     marker=cellstr(marker(sizeOrder,:));   else     marker=Property.marker;   end   % som_cplane can't draw one unit with arbitrary   % coordinates as it its mixed with msize:   if size(coord,1)==1 & strcmp(mode,'lattice'),     spotSize = [spotSize; spotSize];     coord = [coord; coord];   end   N=length(notZero); % for som_grid visuzalization routine case 'pie'  % marker 'pie' requires size parameter totHits  if strcmp(mode,'pie')    coord=som_vis_coords(lattice, msize);    notZero=sum(Hits,2)>0;    Hits=Hits(notZero,:);    coord=coord(notZero,:);    N=size(notZero,1);    totHits=sqrt(sum(Hits,2)./max(sum(Hits,2)));  end    % som_pieplane can't draw one unit with arbitrary  % coordinates as it its mixed with msize:  if size(coord,1)==1,    Hits= [Hits; Hits];    coord = [coord; coord];  end otherwise  error('Whoops: internal error. Bad mode in subfunction mhit');endfor i=1:length(p),    %%% Main loop begins

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -