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

📄 vis_trajgui.m

📁 it is matlab code , som(slef organizing map) tool for matlab
💻 M
📖 第 1 页 / 共 3 页
字号:
  delete([udata.t_line.h2 udata.t_line.h]);  if ~isempty(udata.fig2)    delete([udata.t_line2.h2 udata.t_line2.h]);  end  set(get(udata.THIS,'Parent'),'WindowButtonMotionFcn','',...		    'WindowButtonUpFcn','');  udata=rmfield(udata,'THIS');endset(udata.fig1,'UserData',udata);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function draw_markers(x);plot2data(x);plot2plane(x);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function plot2data(x);% plot black markers to the data figure(s)udata=get(gcf,'UserData');udata=get(udata.fig1,'UserData');old = gcf;set(0,'CurrentFigure',udata.fig1);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if there already exist points in the positions that are members% of the set x, then the old points are removed from data figures...for i=1:length(udata.d_mark(1).h)  tmp1 = get(udata.d_mark(1).h(i),'XData');  tmp2 = setdiff(tmp1,x);  if length(tmp1) ~= length(tmp2)    inds=[];    for j=1:length(tmp2);      inds=[inds find(tmp2(j)==tmp1)];    end    for j=1:length(udata.d_mark)      ydata=getfield(get(udata.d_mark(j).h(i),'YData'),{inds});      set(udata.d_mark(j).h(i),'XData',tmp2,'YData',ydata);    end    if ~isempty(udata.fig2)      for j=1:length(udata.d_mark2)        ydata=getfield(get(udata.d_mark2(j).h(i),'YData'),{inds});        set(udata.d_mark2(j).h(i),'XData',tmp2,'YData',ydata);      end    end  endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ... and the new ones are plotted.for i=1:length(udata.h)  subplot(udata.h(i));  h=plot(x,getfield(get(udata.d(i),'YData'),{x}),'oblack',...	 'ButtonDownFcn',...	 'vis_trajgui([],''line_down'')');  udata.d_mark(i).h=[udata.d_mark(i).h;h];endif ~isempty(udata.h2)  set(0,'CurrentFigure',udata.fig2);    for i=1:length(udata.h2)    subplot(udata.h2(i));    h=plot(x,getfield(get(udata.d2(i),'YData'),{x}),'oblack',...	   'ButtonDownFcn',...	   'vis_trajgui([],''line_down'')');    udata.d_mark2(i).h=[udata.d_mark2(i).h;h];  endendset(0,'CurrentFigure',old);set(udata.fig1,'UserData',udata);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function plot2plane(x);% sets markers to the component planes.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% actually new markers are never plotted, but the color of the patch% lying above the original component plane patch is changed black in% the right positions.udata=get(gcf,'UserData');udata=get(udata.fig1,'UserData');udata.new_marks=unique([udata.new_marks ;x']);for i=1:length(udata.a_h)  col=get(udata.tmp_patch(i),'FaceVertexCData');  if length(size(col)) == 3    col = reshape(col,[size(col,1) 3]);  end  for j=1:length(udata.new_marks)    col(udata.bmus(udata.new_marks(j)),:)=[0 0 0];  end  set(udata.tmp_patch(i),'FaceVertexCData',col);endset(udata.fig1,'UserData',udata);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function color_gui(fig1)% construct the graphical user interface for changing the color of the% black (marked) nodes.udata=get(fig1,'UserData');a = figure('Color',[0.8 0.8 0.8], ...	   'Name','Colors', ...	   'PaperType','a4letter', ...	   'Position',[518 456 120 311], ...	   'Tag','Fig1');udata.c_struct.fig=a;b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.701961 0.701961 0.701961], ...	      'Position',[0.0700415 0.28956 0.830492 0.594566], ...	      'Style','frame', ...	      'Tag','Frame1');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.8 0.8 0.8], ...	      'Position',[0.100059 0.301143 0.770456 0.571399], ...	      'Style','frame', ...	      'Tag','Frame2');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'Callback','vis_trajgui([],''cyan'')', ...	      'Position',[0.130077 0.795326 0.170101 0.0617729], ...	      'Style','radiobutton', ...	      'Tag','cyan', ...	      'Value',1);b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'Callback','vis_trajgui([],''magenta'')', ...	      'Position',[0.130077 0.733553 0.170101 0.057912], ...	      'Style','radiobutton', ...	      'Tag','magenta');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'Callback','vis_trajgui([],''yellow'')', ...	      'Position',[0.130077 0.664059 0.170101 0.0617729], ...	      'Style','radiobutton', ...	      'Tag','yellow');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'Callback','vis_trajgui([],''red'')', ...	      'Position',[0.130077 0.590703 0.170101 0.0617729], ...	      'Style','radiobutton', ...	      'Tag','red');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'Callback','vis_trajgui([],''green'')', ...	      'Position',[0.130077 0.525068 0.170101 0.057912], ...	      'Style','radiobutton', ...	      'Tag','green');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'Callback','vis_trajgui([],''blue'')', ...	      'Position',[0.130077 0.455575 0.170101 0.0617729], ...	      'Style','radiobutton', ...	      'Tag','blue');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'Callback','vis_trajgui([],''white'')', ...	      'Position',[0.130077 0.38608 0.170101 0.0617729], ...	      'Style','radiobutton', ...	      'Tag','white');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'Callback','vis_trajgui([],''grey'')', ...	      'Position',[0.130077 0.320447 0.170101 0.057912], ...	      'Style','radiobutton', ...	      'Tag','grey');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.8 0.8 0.8], ...	      'FontWeight','demi', ...	      'HorizontalAlignment','left', ...	      'Position',[0.32019 0.795326 0.470278 0.0501905], ...	      'String','Cyan', ...	      'Style','text', ...	      'Tag','StaticText1');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.8 0.8 0.8], ...	      'FontWeight','demi', ...	      'HorizontalAlignment','left', ...	      'Position',[0.32019 0.733553 0.520308 0.0463296], ...	      'String','Magenta', ...	      'Style','text', ...	      'Tag','StaticText2');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.8 0.8 0.8], ...	      'FontWeight','demi', ...	      'HorizontalAlignment','left', ...	      'Position',[0.32019 0.664059 0.470278 0.0501905], ...	      'String','Yellow', ...	      'Style','text', ...	      'Tag','StaticText3');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.8 0.8 0.8], ...	      'FontWeight','demi', ...	      'HorizontalAlignment','left', ...	      'Position',[0.32019 0.590703 0.470278 0.0501905], ...	      'String','Red', ...	      'Style','text', ...	      'Tag','StaticText4');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.8 0.8 0.8], ...	      'FontWeight','demi', ...	      'HorizontalAlignment','left', ...	      'Position',[0.32019 0.525068 0.470278 0.0463296], ...	      'String','Green', ...	      'Style','text', ...	      'Tag','StaticText5');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.8 0.8 0.8], ...	      'FontWeight','demi', ...	      'HorizontalAlignment','left', ...	      'Position',[0.32019 0.455575 0.470278 0.0463296], ...	      'String','Blue', ...	      'Style','text', ...	      'Tag','StaticText6');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.8 0.8 0.8], ...	      'FontWeight','demi', ...	      'HorizontalAlignment','left', ...	      'Position',[0.32019 0.38608 0.470278 0.0501905], ...	      'String','White', ...	      'Style','text', ...	      'Tag','StaticText7');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.8 0.8 0.8], ...	      'FontWeight','demi', ...	      'HorizontalAlignment','left', ...	      'Position',[0.32019 0.320447 0.470278 0.0463296], ...	      'String','Grey', ...	      'Style','text', ...	      'Tag','StaticText8');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'Position',[0.0700415 0.146711 0.830492 0.135128], ...	      'Style','frame', ...	      'Tag','Frame3');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.8 0.8 0.8], ...	      'Position',[0.100059 0.158293 0.770456 0.111963], ...	      'Style','frame', ...	      'Tag','Frame4');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[0.8 0.8 0.8], ...	      'FontWeight','demi', ...	      'HorizontalAlignment','left', ...	      'Position',[0.130077 0.177597 0.270833 0.0617729], ...	      'String','RGB', ...	      'Style','text', ...	      'Tag','StaticText9');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'BackgroundColor',[1 1 1], ...	      'Position',[0.410243 0.173736 0.420249 0.0810768], ...	      'Style','edit', ...	      'Tag','EditText1');udata.c_struct.RGB=b;b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'Callback','vis_trajgui([],''dye'')', ...	      'FontWeight','demi', ...	      'Position',[0.0700415 0.0270256 0.360214 0.0772162], ...	      'String','OK', ...	      'Tag','Pushbutton1');b = uicontrol('Parent',a, ...	      'Units','normalized', ...	      'Callback','close gcf', ...	      'FontWeight','demi', ...	      'Position',[0.54032 0.0270256 0.360214 0.0772162], ...	      'String','Close', ...	      'Tag','Pushbutton2');udata.c_struct.color=[0 1 1];tmp.fig1=fig1;set(a,'UserData',tmp);set(udata.fig1,'UserData',udata);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function dye_nodes(arg)% takes care of the action, when radiobuttons are pressed % (or the RGB value is set) in the color_gui -figure.% It also handles the starting of dying nodes and plots.udata=get(gcf,'UserData');udata=get(udata.fig1,'UserData');switch arg case {'cyan','magenta','yellow','red','green','blue','white','grey'}  h=findobj(get(gcf,'Children'),'Style','radiobutton');  set(h,'Value',0);  set(gcbo,'Value',1);endswitch arg case 'cyan'  RGB = [0 1 1]; case 'magenta'  RGB = [1 0 1]; case 'yellow'  RGB = [1 1 0]; case 'red'  RGB = [1 0 0]; case 'green'  RGB = [0 1 0]; case 'blue'  RGB = [0 0 1]; case 'white'  RGB = [1 1 1]; case 'grey'  RGB = [0.4 0.4 0.4]; case 'dye'    RGB = get(udata.c_struct.RGB,'String');  if isempty(RGB)    dye;    return;  else    str1='The value of RGB must be vector containing three scalars';    str2='between 0 and 1.';    color = str2num(RGB);    set(udata.c_struct.RGB,'String','');    if isempty(color)      close gcf;      udata=rmfield(udata,'c_struct');      set(udata.fig1,'UserData',udata);      errordlg([{str1};{str2}]);      return;    end    if ~all([1 3] == size(color)) & ~all([3 1] == size(color))      close gcf;      errordlg([{str1};{str2}]);      udata=rmfield(udata,'c_struct',udata);      set(udata.fig1,'UserData',udata);      return;    end    if ~isempty(cat(2,find(color>1),find(color<0)))      close gcf      errordlg([{str1};{str2}]);      udata=rmfield(udata,'c_struct',udata);      set(udata.fig1,'UserData',udata);      return;    end    udata.c_struct.color=color;    set(udata.fig1,'UserData',udata);    dye;    return;  endendudata.c_struct.color=RGB;set(udata.fig1,'UserData',udata);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function dye()% dyes black markers in the component planes and in the data figuresudata=get(gcf,'UserData');udata=get(udata.fig1,'UserData');inds=unique([udata.all_marks ; udata.new_marks]);for i=1:length(udata.d_mark);  for j=1:length(udata.d_mark(i).h)    if all(get(udata.d_mark(i).h(j),'Color') == [0 0 0])      set(udata.d_mark(i).h(j),'Color',udata.c_struct.color);    end  endendif ~isempty(udata.fig2);  for i=1:length(udata.d_mark2)    for j=1:length(udata.d_mark2(i).h)      if all(get(udata.d_mark2(i).h(j),'Color') == [0 0 0])        set(udata.d_mark2(i).h(j),'Color',udata.c_struct.color);      end    end  endendfor i=1:length(udata.a_h)  col=get(udata.tmp_patch(i),'FaceVertexCData');  for j=1:length(udata.new_marks)    col(udata.bmus(udata.new_marks(j)),:)=udata.c_struct.color;  end  set(udata.tmp_patch(i),'FaceVertexCData',col);endudata.all_marks=unique([udata.all_marks;udata.new_marks]);udata.new_marks=[];close gcf;udata=rmfield(udata,'c_struct');set(udata.fig1,'UserData',udata);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function clear_markers()% removes markers from the componentplanes and the data figure(s).udata=get(gcf,'UserData');udata=get(udata.fig1,'UserData');for i=1:length(udata.d_mark)  delete(udata.d_mark(i).h);  udata.d_mark(i).h=[];endfor i=1:length(udata.d_mark2)  delete(udata.d_mark2(i).h);  udata.d_mark2(i).h=[];endcol=NaN*get(udata.tmp_patch(1),'FaceVertexCData');col=reshape(col,[size(col,1) 3]);for i=1:length(udata.tmp_patch)  set(udata.tmp_patch(i),'FaceVertexCData',col);endudata.new_marks=[];udata.all_marks=[];if any(strcmp('c_struct',fieldnames(udata)))  udata=rmfield(udata,'c_struct');endset(udata.fig1,'UserData',udata);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function key_bdf% moves trajectory and pointer lines, when either of % the keys '>' or '<' is pressed.udata=get(gcf,'UserData');udata=get(udata.fig1,'UserData');key=get(gcbo,'CurrentCharacter');% The easiest way to get a new coordinates is to get them from the texts...% The texts are either '<- x' or 'x ->' x=get(udata.text1(1),'String');x=str2num(x(4:length(x)));if isempty(x)  x=get(udata.text1(1),'String');  x=str2num(x(1:length(x)-3));endswitch(key) case '<'  if x ~= 1    x= x-1;  end case '>'  if x ~= getfield(get(get(udata.text1(1),'Parent'),'XLim'),{2})     x = x+1;  end otherwise  return;endset(udata.l,'XData',[x x]);if ~isempty(udata.fig2)  set(udata.l2,'XData',[x x]);enddelete(udata.text1);delete(udata.text2);set_numbers(x);draw_traj(x);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function click()switch get(gcf,'SelectionType') case 'open'  return;

⌨️ 快捷键说明

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