Daniel@0: function vis_trajgui(trajStruct,arg) Daniel@0: Daniel@0: % VIS_TRAJGUI subfuntion for SOM_TRAJECTORY Daniel@0: % Daniel@0: % This function is the actual GUI called by SOM_TRAJECTORY Daniel@0: % function. Daniel@0: % Daniel@0: % See also SOM_TRAJECTORY. Daniel@0: Daniel@0: % Contributed code to SOM Toolbox 2.0, February 11th, 2000 by Juha Parhankangas Daniel@0: % Copyright (c) by Juha Parhankangas. Daniel@0: % http://www.cis.hut.fi/projects/somtoolbox/ Daniel@0: Daniel@0: % Version 2.0beta juha 180699 Daniel@0: Daniel@0: if nargin == 1 Daniel@0: Daniel@0: sM_h=trajStruct.figure; Daniel@0: Daniel@0: if size(trajStruct.bmus,1) ~= 1 & size(trajStruct.bmus,2) ~= 1 Daniel@0: fuzzy_traj(trajStruct,[]); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: if size(trajStruct.bmus,1) == 1 | size(trajStruct.bmus,2) == 1 Daniel@0: Daniel@0: udata.bmus = trajStruct.bmus; Daniel@0: udata.a_h=[findobj(get(sM_h,'Children'),'Tag','Uplane');... Daniel@0: findobj(get(sM_h,'Children'),'Tag','Cplane')]; Daniel@0: udata.sM_h=trajStruct.figure; Daniel@0: udata.traj=[]; Daniel@0: data1 = trajStruct.primary_data; Daniel@0: if ~isempty(trajStruct.primary_names) Daniel@0: names=trajStruct.primary_names; Daniel@0: else Daniel@0: for i=1:size(data1,2) Daniel@0: names{i,1}=sprintf('Var%d',i); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: udata.lattice=trajStruct.lattice; Daniel@0: form = 0.7*vis_patch(udata.lattice); Daniel@0: udata.msize = trajStruct.msize; Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: % Daniel@0: % forming a patch object, which is placed above every component plane Daniel@0: % Daniel@0: Daniel@0: Daniel@0: l = size(form,1); Daniel@0: Daniel@0: nx = repmat(form(:,1),1,prod(udata.msize)); Daniel@0: ny = repmat(form(:,2),1,prod(udata.msize)); Daniel@0: Daniel@0: x=reshape(repmat(1:udata.msize(2),l*udata.msize(1),1),l,prod(udata.msize)); Daniel@0: y=repmat(repmat(1:udata.msize(1),l,1),1,udata.msize(2)); Daniel@0: Daniel@0: if strcmp(udata.lattice,'hexa') Daniel@0: t = find(~rem(y(1,:),2)); Daniel@0: x(:,t)=x(:,t)+.5; Daniel@0: end Daniel@0: x=x+nx; Daniel@0: y=y+ny; Daniel@0: Daniel@0: colors=reshape(ones(prod(udata.msize),1)*[NaN NaN NaN],... Daniel@0: [1 prod(udata.msize) 3]); Daniel@0: Daniel@0: set(0,'CurrentFigure',udata.sM_h); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%% Daniel@0: % Daniel@0: % drawing patch Daniel@0: % Daniel@0: % caxis -commands keep the colormap of the original patch unchanged. Daniel@0: % Daniel@0: Daniel@0: for i=1:length(udata.a_h) Daniel@0: udata.real_patch(i)=get(udata.a_h(i),'Children'); Daniel@0: set(udata.real_patch(i),'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],''click'')'); Daniel@0: subplot(udata.a_h(i)); Daniel@0: v=caxis; Daniel@0: udata.tmp_patch(i)=patch(x,y,colors,'EdgeColor','none',... Daniel@0: 'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],''click'')',... Daniel@0: 'Tag','TmpPatch'); Daniel@0: caxis(v); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: Daniel@0: Daniel@0: udata.length_of_traj=length(trajStruct.size); Daniel@0: udata.size=trajStruct.size; Daniel@0: udata.color=trajStruct.color; Daniel@0: udata.poly.x=[]; Daniel@0: udata.poly.y=[]; Daniel@0: udata.poly.h=[]; Daniel@0: udata.new_marks=[]; Daniel@0: udata.all_marks=[]; Daniel@0: udata.d_mark2=[]; Daniel@0: udata.fig1 = figure; Daniel@0: set(udata.fig1,'KeyPressFcn','vis_trajgui([],''key'')',... Daniel@0: 'Name','Primary Data'); Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%% Daniel@0: % Daniel@0: % making the 'Tools' -menu Daniel@0: % Daniel@0: Daniel@0: udata.m_i=uimenu(udata.fig1,'Label','Trajectoy T&ools'); Daniel@0: udata.m_i(2)=uimenu(udata.m_i,'Label','&Remove Trajectory',... Daniel@0: 'Callback',... Daniel@0: 'vis_trajgui([],''remove_traj'')'); Daniel@0: udata.m_i(3)=uimenu(udata.m_i(1),'Label','&Dye Nodes',... Daniel@0: 'Callback',... Daniel@0: 'vis_trajgui([],''dye_gui'')'); Daniel@0: udata.m_i(4)=uimenu(udata.m_i(1),'Label','&Clear Markers',... Daniel@0: 'Callback',... Daniel@0: 'vis_trajgui([],''clear'')'); Daniel@0: udata.m_i(5)=uimenu(udata.m_i(1),'Label','&Save',... Daniel@0: 'Callback',... Daniel@0: 'vis_trajgui([],''save'')'); Daniel@0: udata.m_i(6)=uimenu(udata.m_i(1),'Label','&Load',... Daniel@0: 'Callback',... Daniel@0: 'vis_trajgui([],''load'')'); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: % Daniel@0: % drawing data components to the figure .... Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: if nargin < 5 | isempty(comps) | (isstr(comps) & strcmp(comps,'all')) Daniel@0: comps = 1:size(data1,2); Daniel@0: end Daniel@0: Daniel@0: x=1:size(data1,1); Daniel@0: Daniel@0: for i=1:length(comps) Daniel@0: subplot(length(comps),1,i); Daniel@0: udata.h(i)=gca; Daniel@0: udata.d_mark(i).h=[]; Daniel@0: Daniel@0: udata.d(i)=plot(x,data1(:,comps(i)),... Daniel@0: 'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],''line_down'')'); Daniel@0: set(gca,'XLim',[1 size(data1,1)],... Daniel@0: 'XTick',[],... Daniel@0: 'ButtonDownFcn','vis_trajgui([],''line_down'')'); %,... Daniel@0: %'YLim',[min(data1(:,comps(i))) max(data1(:,comps(i)))]); Daniel@0: Daniel@0: ylabel(names{comps(i)}); Daniel@0: hold on; Daniel@0: ymin=get(udata.h(i),'YLim'); Daniel@0: pos=mean(get(udata.h(i),'XLim')); Daniel@0: udata.l(i) = line([pos pos],[ymin(1) ymin(2)],... Daniel@0: 'Color','red',... Daniel@0: 'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],''down'')'); Daniel@0: end Daniel@0: udata.text1=[]; Daniel@0: Daniel@0: udata.fig2=[]; Daniel@0: udata.h2=[]; Daniel@0: udata.l2=[]; Daniel@0: udata.text2=[]; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: % Daniel@0: % ... and to the figure 2. Daniel@0: % Daniel@0: Daniel@0: Daniel@0: if ~isempty(trajStruct.secondary_data) Daniel@0: data2=trajStruct.secondary_data; Daniel@0: if isempty(trajStruct.secondary_names) Daniel@0: for i=1:size(data1,2) Daniel@0: names2{i,1}=sprintf('Var%d',i); Daniel@0: end Daniel@0: else Daniel@0: names2=trajStruct.secondary_names; Daniel@0: end Daniel@0: Daniel@0: udata.fig2 = figure; Daniel@0: set(udata.fig2,'Name','Secondary Data'); Daniel@0: set(udata.fig2,'KeyPressFcn',... Daniel@0: 'vis_trajgui([],''key'')'); Daniel@0: for i=1:size(data2,2) Daniel@0: subplot(size(data2,2),1,i); Daniel@0: udata.h2(i) = gca; Daniel@0: udata.d_mark2(i).h=[]; Daniel@0: udata.d2(i) = plot(x,data2(:,i),... Daniel@0: 'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],''line_down'')'); Daniel@0: set(gca,'XLim',[1 size(data1,1)],'XTick',[],'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],[],[],[],[],[],''line_down'')'); Daniel@0: ylabel(names2{i}); Daniel@0: hold on; Daniel@0: ymin = get(udata.h2(i),'YLim'); Daniel@0: pos = mean(get(udata.h2(i),'XLim')); Daniel@0: udata.l2(i) = line([pos pos],ymin,'Color','red',... Daniel@0: 'ButtonDownFcn','vis_trajgui([],''down'')'); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: if ~isempty(udata.fig2); Daniel@0: tmp.fig1=udata.fig1; Daniel@0: set(udata.fig2,'UserData',tmp); Daniel@0: end Daniel@0: tmp=get(udata.sM_h,'UserData'); Daniel@0: tmp.fig1=udata.fig1; Daniel@0: set(udata.sM_h,'UserData',tmp); Daniel@0: set_numbers(round(pos)); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%% Daniel@0: % Daniel@0: % if figures have been drawn, the only function calls that may exist Daniel@0: % are the ones that change the state of the application. Daniel@0: % Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: switch arg Daniel@0: case 'fuzzy' Daniel@0: fuzzy_traj(tS,[]); Daniel@0: return; Daniel@0: case 'move_fuzzy' Daniel@0: fuzzy_traj([],'move'); Daniel@0: return; Daniel@0: case 'remove_traj' Daniel@0: remove_traj; Daniel@0: return; Daniel@0: case 'line_down' Daniel@0: line_bdf('down'); Daniel@0: return; Daniel@0: case 'line_drag' Daniel@0: line_bdf('drag'); Daniel@0: return; Daniel@0: case 'line_up' Daniel@0: line_bdf('up'); Daniel@0: return; Daniel@0: case 'dye_gui'; Daniel@0: color_gui(udata.fig1); Daniel@0: return; Daniel@0: case {'dye','cyan','magenta','yellow','red','green','blue','white','grey'} Daniel@0: dye_nodes(arg); Daniel@0: return; Daniel@0: case 'clear' Daniel@0: clear_markers; Daniel@0: return; Daniel@0: case 'key' Daniel@0: key_bdf; Daniel@0: return; Daniel@0: case 'click' Daniel@0: click; Daniel@0: return; Daniel@0: case 'save' Daniel@0: save_data; Daniel@0: return; Daniel@0: case 'load' Daniel@0: load_data; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%% Daniel@0: % Daniel@0: % lines in the data figure(s) are dragged ... Daniel@0: % Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: Daniel@0: lims=get(gca,'XLim'); Daniel@0: x = getfield(get(gca,'CurrentPoint'),{1}); % the location of the line Daniel@0: Daniel@0: if x < lims(1) Daniel@0: x=lims(1); Daniel@0: elseif x > lims(2) Daniel@0: x=lims(2); Daniel@0: end Daniel@0: Daniel@0: old = gcf; Daniel@0: Daniel@0: switch arg Daniel@0: case 'down',... Daniel@0: Daniel@0: % mouse button is pressed down above the line Daniel@0: Daniel@0: set(gcf,'WindowButtonMotionFcn','vis_trajgui([],''drag'')'); Daniel@0: set(gcf,'WindowButtonUpFcn','vis_trajgui([],''up'')'); Daniel@0: set(udata.l,'EraseMode','xor'); Daniel@0: delete(udata.text1); Daniel@0: if ~isempty(udata.l2); Daniel@0: set(udata.l2,'EraseMode','xor'); Daniel@0: delete(udata.text2); Daniel@0: end Daniel@0: set(gcf,'Pointer','crosshair'); Daniel@0: Daniel@0: case 'drag' Daniel@0: % change the location of the lines Daniel@0: Daniel@0: set(0,'CurrentFigure',udata.fig1); Daniel@0: set(udata.l,'XData',[x x]); Daniel@0: if ~isempty(udata.fig2) Daniel@0: set(0,'CurrentFigure',udata.fig2); Daniel@0: set(udata.l2,'XData',[x x]); Daniel@0: end Daniel@0: draw_traj(round(x)); Daniel@0: set(0,'CurrentFigure',old); Daniel@0: case 'up' Daniel@0: Daniel@0: % draw trajectory and set figure to the normal state. Daniel@0: Daniel@0: set(udata.l,'EraseMode','normal'); Daniel@0: set(gcf,'Pointer','arrow','WindowButtonMotionFcn','',... Daniel@0: 'WindowButtonUpFcn',''); Daniel@0: draw_traj(round(x)); Daniel@0: set_numbers(round(x)); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function draw_traj(point) Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: color=udata.color; Daniel@0: eMode='normal'; Daniel@0: if isstr(udata.color) & strcmp(udata.color,'xor') Daniel@0: eMode='xor'; Daniel@0: color='black'; Daniel@0: end Daniel@0: ind=udata.bmus(point); Daniel@0: [i j] = ind2sub(udata.msize,ind); Daniel@0: if ~mod(i,2) Daniel@0: j=j+0.5; Daniel@0: end Daniel@0: old = gcf; Daniel@0: set(0,'CurrentFigure',udata.sM_h); Daniel@0: hold on; Daniel@0: if isempty(udata.traj) | length(udata.traj.h) ~= length(udata.a_h) Daniel@0: Daniel@0: % trajectory does not exist Daniel@0: Daniel@0: for i=1:length(udata.a_h) Daniel@0: subplot(udata.a_h(i)); Daniel@0: hold on; Daniel@0: new.h = plot(j,i,'Color',color,'EraseMode',eMode,'LineStyle','none'); Daniel@0: udata.traj.h(i)=new; Daniel@0: udata.traj.j=j; Daniel@0: udata.traj.i=i; Daniel@0: end Daniel@0: else Daniel@0: if length(udata.traj.j) == udata.length_of_traj Daniel@0: % if the length of trajectory == ..., Daniel@0: udata.traj.j(1) = []; % the first (the oldest) coordinate pair Daniel@0: udata.traj.i(1) = []; % is removed. Daniel@0: end Daniel@0: udata.traj.j=[udata.traj.j;j]; % the new point is added to the Daniel@0: udata.traj.i=[udata.traj.i;i]; % end of coordinate vectors (i and j) Daniel@0: for i=1:length(udata.a_h) Daniel@0: subplot(udata.a_h(i)); % remove the existing trajectory Daniel@0: delete(udata.traj.h(i).h); % and plot the new one. Daniel@0: for j=1:length(udata.traj.j) Daniel@0: udata.traj.h(i).h(j)=plot(udata.traj.j(j),udata.traj.i(j),... Daniel@0: 'Color',color,... Daniel@0: 'EraseMode',eMode,'Marker','o','LineWidth',2,... Daniel@0: 'MarkerSize',udata.size(udata.length_of_traj-j+1),... Daniel@0: 'LineStyle','none'); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: set(0,'CurrentFigure',udata.fig1); Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function set_numbers(x); Daniel@0: Daniel@0: % This function writes the numbers beside of the pointer lines Daniel@0: Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: xlim = get(gca,'XLim'); Daniel@0: ylim = get(gca,'YLim'); Daniel@0: p = ylim(1) + 0.9*(ylim(2)-ylim(1)); Daniel@0: Daniel@0: old = gcf; Daniel@0: set(0,'CurrentFigure',udata.fig1); Daniel@0: Daniel@0: Daniel@0: for i=1:length(udata.h) Daniel@0: subplot(udata.h(i)); Daniel@0: Daniel@0: % check if the text is placed to the left side of the line... Daniel@0: Daniel@0: if abs(x-xlim(1)) > (abs(x-xlim(2))) Daniel@0: udata.text1(i)=text(x-1,p,sprintf('%d ->',x),... Daniel@0: 'VerticalAlignment','top',... Daniel@0: 'HorizontalAlignment','right',... Daniel@0: 'FontWeight','demi'); Daniel@0: else Daniel@0: Daniel@0: % or to the right side. Daniel@0: Daniel@0: udata.text1(i)=text(x+1,p,sprintf('<- %d',x),... Daniel@0: 'VerticalAlignment','top',... Daniel@0: 'FontWeight','demi'); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: if ~isempty(udata.fig2) Daniel@0: set(0,'CurrentFigure',udata.fig2); Daniel@0: Daniel@0: for i=1:length(udata.h2) Daniel@0: subplot(udata.h2(i)); Daniel@0: Daniel@0: if abs(x-xlim(1)) > (abs(x-xlim(2))) Daniel@0: udata.text2(i)=text(x-1,p,sprintf('%d ->',x),... Daniel@0: 'VerticalAlignment','top',... Daniel@0: 'HorizontalAlignment','right',... Daniel@0: 'FontWeight','demi'); Daniel@0: else Daniel@0: udata.text2(i)=text(x+1,p,sprintf('<- %d',x),... Daniel@0: 'VerticalAlignment','top',... Daniel@0: 'FontWeight','demi'); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: set(0,'CurrentFigure',old); Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function remove_traj() Daniel@0: Daniel@0: % delete trajectory -object from every component plane. Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: if isempty(udata.traj) Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: for i=1:length(udata.traj.h) Daniel@0: delete(udata.traj.h(i).h); Daniel@0: end Daniel@0: Daniel@0: udata.traj=[]; Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function line_bdf(arg) Daniel@0: Daniel@0: % this function takes care of action when region is selected in the Daniel@0: % data figure. Daniel@0: Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: xlim=get(gca,'XLim'); Daniel@0: Daniel@0: if ~(any(strcmp('THIS',fieldnames(udata)))) Daniel@0: p = getfield(get(gca,'CurrentPoint'),{1}); Daniel@0: else Daniel@0: p = getfield(get(udata.THIS,'CurrentPoint'),{1}); Daniel@0: end Daniel@0: Daniel@0: if p < xlim(1) Daniel@0: p = xlim(1); Daniel@0: elseif p > xlim(2) Daniel@0: p = xlim(2); Daniel@0: end Daniel@0: Daniel@0: Daniel@0: Daniel@0: switch arg Daniel@0: case 'down' Daniel@0: Daniel@0: % the mouse button is pressed down, the pointer lines are drawn. Daniel@0: % and the state of the figure is changed. Daniel@0: Daniel@0: udata.THIS=gca; Daniel@0: set(gcf,'WindowButtonMotionFcn',... Daniel@0: 'vis_trajgui([],''line_drag'')',... Daniel@0: 'WindowButtonUpFcn','vis_trajgui([],''line_up'')'); Daniel@0: udata.start_p=p; Daniel@0: Daniel@0: old = gcf; Daniel@0: set(0,'CurrentFigure',udata.fig1); Daniel@0: Daniel@0: for i=1:length(udata.h) Daniel@0: subplot(udata.h(i)); Daniel@0: udata.t_line.h(i)=line([p p],get(gca,'YLim'),'Color','red'); Daniel@0: udata.t_line.h2(i)=line([p p],get(gca,'YLim'),'Color','red',... Daniel@0: 'EraseMode','xor'); Daniel@0: end Daniel@0: if ~isempty(udata.h2) Daniel@0: set(0,'CurrentFigure',udata.fig2); Daniel@0: for i=1:length(udata.h2) Daniel@0: subplot(udata.h2(i)); Daniel@0: udata.t_line2.h(i)=line([p p],get(gca,'YLim'),'Color','red'); Daniel@0: udata.t_line2.h2(i)=line([p p],get(gca,'YLim'),'Color','red',... Daniel@0: 'EraseMode','xor'); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: case 'drag' Daniel@0: Daniel@0: % change the position of the pointer lines Daniel@0: Daniel@0: old = gcf; Daniel@0: set(0,'CurrentFigure',udata.fig1); Daniel@0: set(udata.t_line.h2,'XData',[p p]); Daniel@0: if ~isempty(udata.fig2) Daniel@0: set(0,'CurrentFigure',udata.fig2); Daniel@0: set(udata.t_line2.h2,'XData',[p p]); Daniel@0: end Daniel@0: set(0,'CurrentFigure',old); Daniel@0: case 'up' Daniel@0: Daniel@0: Daniel@0: % sort the 'points' -vector and draw the markers to the data and nodes Daniel@0: Daniel@0: points=sort([round(udata.start_p) round(p)]); Daniel@0: draw_markers(points(1):points(2)); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: udata.new_marks=unique([udata.new_marks ;(points(1):points(2))']); Daniel@0: delete([udata.t_line.h2 udata.t_line.h]); Daniel@0: if ~isempty(udata.fig2) Daniel@0: delete([udata.t_line2.h2 udata.t_line2.h]); Daniel@0: end Daniel@0: set(get(udata.THIS,'Parent'),'WindowButtonMotionFcn','',... Daniel@0: 'WindowButtonUpFcn',''); Daniel@0: udata=rmfield(udata,'THIS'); Daniel@0: end Daniel@0: Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function draw_markers(x); Daniel@0: Daniel@0: plot2data(x); Daniel@0: plot2plane(x); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function plot2data(x); Daniel@0: Daniel@0: % plot black markers to the data figure(s) Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: old = gcf; Daniel@0: Daniel@0: set(0,'CurrentFigure',udata.fig1); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: % if there already exist points in the positions that are members Daniel@0: % of the set x, then the old points are removed from data figures... Daniel@0: Daniel@0: for i=1:length(udata.d_mark(1).h) Daniel@0: tmp1 = get(udata.d_mark(1).h(i),'XData'); Daniel@0: tmp2 = setdiff(tmp1,x); Daniel@0: if length(tmp1) ~= length(tmp2) Daniel@0: inds=[]; Daniel@0: for j=1:length(tmp2); Daniel@0: inds=[inds find(tmp2(j)==tmp1)]; Daniel@0: end Daniel@0: for j=1:length(udata.d_mark) Daniel@0: ydata=getfield(get(udata.d_mark(j).h(i),'YData'),{inds}); Daniel@0: set(udata.d_mark(j).h(i),'XData',tmp2,'YData',ydata); Daniel@0: end Daniel@0: if ~isempty(udata.fig2) Daniel@0: for j=1:length(udata.d_mark2) Daniel@0: ydata=getfield(get(udata.d_mark2(j).h(i),'YData'),{inds}); Daniel@0: set(udata.d_mark2(j).h(i),'XData',tmp2,'YData',ydata); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: % ... and the new ones are plotted. Daniel@0: Daniel@0: for i=1:length(udata.h) Daniel@0: subplot(udata.h(i)); Daniel@0: h=plot(x,getfield(get(udata.d(i),'YData'),{x}),'oblack',... Daniel@0: 'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],''line_down'')'); Daniel@0: udata.d_mark(i).h=[udata.d_mark(i).h;h]; Daniel@0: end Daniel@0: Daniel@0: if ~isempty(udata.h2) Daniel@0: set(0,'CurrentFigure',udata.fig2); Daniel@0: Daniel@0: for i=1:length(udata.h2) Daniel@0: subplot(udata.h2(i)); Daniel@0: h=plot(x,getfield(get(udata.d2(i),'YData'),{x}),'oblack',... Daniel@0: 'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],''line_down'')'); Daniel@0: udata.d_mark2(i).h=[udata.d_mark2(i).h;h]; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: set(0,'CurrentFigure',old); Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function plot2plane(x); Daniel@0: Daniel@0: % sets markers to the component planes. Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: % Daniel@0: % actually new markers are never plotted, but the color of the patch Daniel@0: % lying above the original component plane patch is changed black in Daniel@0: % the right positions. Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: udata.new_marks=unique([udata.new_marks ;x']); Daniel@0: Daniel@0: for i=1:length(udata.a_h) Daniel@0: col=get(udata.tmp_patch(i),'FaceVertexCData'); Daniel@0: if length(size(col)) == 3 Daniel@0: col = reshape(col,[size(col,1) 3]); Daniel@0: end Daniel@0: for j=1:length(udata.new_marks) Daniel@0: col(udata.bmus(udata.new_marks(j)),:)=[0 0 0]; Daniel@0: end Daniel@0: set(udata.tmp_patch(i),'FaceVertexCData',col); Daniel@0: end Daniel@0: Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function color_gui(fig1) Daniel@0: Daniel@0: % construct the graphical user interface for changing the color of the Daniel@0: % black (marked) nodes. Daniel@0: Daniel@0: Daniel@0: udata=get(fig1,'UserData'); Daniel@0: Daniel@0: a = figure('Color',[0.8 0.8 0.8], ... Daniel@0: 'Name','Colors', ... Daniel@0: 'PaperType','a4letter', ... Daniel@0: 'Position',[518 456 120 311], ... Daniel@0: 'Tag','Fig1'); Daniel@0: Daniel@0: udata.c_struct.fig=a; Daniel@0: Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.701961 0.701961 0.701961], ... Daniel@0: 'Position',[0.0700415 0.28956 0.830492 0.594566], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame1'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Position',[0.100059 0.301143 0.770456 0.571399], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame2'); Daniel@0: Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','vis_trajgui([],''cyan'')', ... Daniel@0: 'Position',[0.130077 0.795326 0.170101 0.0617729], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','cyan', ... Daniel@0: 'Value',1); Daniel@0: Daniel@0: Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','vis_trajgui([],''magenta'')', ... Daniel@0: 'Position',[0.130077 0.733553 0.170101 0.057912], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','magenta'); Daniel@0: Daniel@0: Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','vis_trajgui([],''yellow'')', ... Daniel@0: 'Position',[0.130077 0.664059 0.170101 0.0617729], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','yellow'); Daniel@0: Daniel@0: Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','vis_trajgui([],''red'')', ... Daniel@0: 'Position',[0.130077 0.590703 0.170101 0.0617729], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','red'); Daniel@0: Daniel@0: Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','vis_trajgui([],''green'')', ... Daniel@0: 'Position',[0.130077 0.525068 0.170101 0.057912], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','green'); Daniel@0: Daniel@0: Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','vis_trajgui([],''blue'')', ... Daniel@0: 'Position',[0.130077 0.455575 0.170101 0.0617729], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','blue'); Daniel@0: Daniel@0: Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','vis_trajgui([],''white'')', ... Daniel@0: 'Position',[0.130077 0.38608 0.170101 0.0617729], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','white'); Daniel@0: Daniel@0: Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','vis_trajgui([],''grey'')', ... Daniel@0: 'Position',[0.130077 0.320447 0.170101 0.057912], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','grey'); Daniel@0: Daniel@0: Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.32019 0.795326 0.470278 0.0501905], ... Daniel@0: 'String','Cyan', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText1'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.32019 0.733553 0.520308 0.0463296], ... Daniel@0: 'String','Magenta', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText2'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.32019 0.664059 0.470278 0.0501905], ... Daniel@0: 'String','Yellow', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText3'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.32019 0.590703 0.470278 0.0501905], ... Daniel@0: 'String','Red', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText4'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.32019 0.525068 0.470278 0.0463296], ... Daniel@0: 'String','Green', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText5'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.32019 0.455575 0.470278 0.0463296], ... Daniel@0: 'String','Blue', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText6'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.32019 0.38608 0.470278 0.0501905], ... Daniel@0: 'String','White', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText7'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.32019 0.320447 0.470278 0.0463296], ... Daniel@0: 'String','Grey', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText8'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Position',[0.0700415 0.146711 0.830492 0.135128], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame3'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Position',[0.100059 0.158293 0.770456 0.111963], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame4'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.130077 0.177597 0.270833 0.0617729], ... Daniel@0: 'String','RGB', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText9'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'Position',[0.410243 0.173736 0.420249 0.0810768], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText1'); Daniel@0: Daniel@0: udata.c_struct.RGB=b; Daniel@0: Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','vis_trajgui([],''dye'')', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'Position',[0.0700415 0.0270256 0.360214 0.0772162], ... Daniel@0: 'String','OK', ... Daniel@0: 'Tag','Pushbutton1'); Daniel@0: b = uicontrol('Parent',a, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','close gcf', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'Position',[0.54032 0.0270256 0.360214 0.0772162], ... Daniel@0: 'String','Close', ... Daniel@0: 'Tag','Pushbutton2'); Daniel@0: Daniel@0: udata.c_struct.color=[0 1 1]; Daniel@0: Daniel@0: tmp.fig1=fig1; Daniel@0: set(a,'UserData',tmp); Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function dye_nodes(arg) Daniel@0: Daniel@0: % takes care of the action, when radiobuttons are pressed Daniel@0: % (or the RGB value is set) in the color_gui -figure. Daniel@0: % It also handles the starting of dying nodes and plots. Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: Daniel@0: switch arg Daniel@0: case {'cyan','magenta','yellow','red','green','blue','white','grey'} Daniel@0: h=findobj(get(gcf,'Children'),'Style','radiobutton'); Daniel@0: set(h,'Value',0); Daniel@0: set(gcbo,'Value',1); Daniel@0: end Daniel@0: Daniel@0: Daniel@0: switch arg Daniel@0: case 'cyan' Daniel@0: RGB = [0 1 1]; Daniel@0: case 'magenta' Daniel@0: RGB = [1 0 1]; Daniel@0: case 'yellow' Daniel@0: RGB = [1 1 0]; Daniel@0: case 'red' Daniel@0: RGB = [1 0 0]; Daniel@0: case 'green' Daniel@0: RGB = [0 1 0]; Daniel@0: case 'blue' Daniel@0: RGB = [0 0 1]; Daniel@0: case 'white' Daniel@0: RGB = [1 1 1]; Daniel@0: case 'grey' Daniel@0: RGB = [0.4 0.4 0.4]; Daniel@0: case 'dye' Daniel@0: Daniel@0: RGB = get(udata.c_struct.RGB,'String'); Daniel@0: if isempty(RGB) Daniel@0: dye; Daniel@0: return; Daniel@0: else Daniel@0: str1='The value of RGB must be vector containing three scalars'; Daniel@0: str2='between 0 and 1.'; Daniel@0: color = str2num(RGB); Daniel@0: set(udata.c_struct.RGB,'String',''); Daniel@0: if isempty(color) Daniel@0: close gcf; Daniel@0: udata=rmfield(udata,'c_struct'); Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: errordlg([{str1};{str2}]); Daniel@0: return; Daniel@0: end Daniel@0: if ~all([1 3] == size(color)) & ~all([3 1] == size(color)) Daniel@0: close gcf; Daniel@0: errordlg([{str1};{str2}]); Daniel@0: udata=rmfield(udata,'c_struct',udata); Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: return; Daniel@0: end Daniel@0: if ~isempty(cat(2,find(color>1),find(color<0))) Daniel@0: close gcf Daniel@0: errordlg([{str1};{str2}]); Daniel@0: udata=rmfield(udata,'c_struct',udata); Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: return; Daniel@0: end Daniel@0: udata.c_struct.color=color; Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: dye; Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: udata.c_struct.color=RGB; Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function dye() Daniel@0: Daniel@0: % dyes black markers in the component planes and in the data figures Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: inds=unique([udata.all_marks ; udata.new_marks]); Daniel@0: Daniel@0: Daniel@0: for i=1:length(udata.d_mark); Daniel@0: for j=1:length(udata.d_mark(i).h) Daniel@0: if all(get(udata.d_mark(i).h(j),'Color') == [0 0 0]) Daniel@0: set(udata.d_mark(i).h(j),'Color',udata.c_struct.color); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: if ~isempty(udata.fig2); Daniel@0: for i=1:length(udata.d_mark2) Daniel@0: for j=1:length(udata.d_mark2(i).h) Daniel@0: if all(get(udata.d_mark2(i).h(j),'Color') == [0 0 0]) Daniel@0: set(udata.d_mark2(i).h(j),'Color',udata.c_struct.color); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: Daniel@0: for i=1:length(udata.a_h) Daniel@0: col=get(udata.tmp_patch(i),'FaceVertexCData'); Daniel@0: for j=1:length(udata.new_marks) Daniel@0: col(udata.bmus(udata.new_marks(j)),:)=udata.c_struct.color; Daniel@0: end Daniel@0: set(udata.tmp_patch(i),'FaceVertexCData',col); Daniel@0: end Daniel@0: Daniel@0: Daniel@0: udata.all_marks=unique([udata.all_marks;udata.new_marks]); Daniel@0: udata.new_marks=[]; Daniel@0: close gcf; Daniel@0: udata=rmfield(udata,'c_struct'); Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function clear_markers() Daniel@0: Daniel@0: % removes markers from the componentplanes and the data figure(s). Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: for i=1:length(udata.d_mark) Daniel@0: delete(udata.d_mark(i).h); Daniel@0: udata.d_mark(i).h=[]; Daniel@0: end Daniel@0: Daniel@0: for i=1:length(udata.d_mark2) Daniel@0: delete(udata.d_mark2(i).h); Daniel@0: udata.d_mark2(i).h=[]; Daniel@0: end Daniel@0: Daniel@0: col=NaN*get(udata.tmp_patch(1),'FaceVertexCData'); Daniel@0: col=reshape(col,[size(col,1) 3]); Daniel@0: Daniel@0: for i=1:length(udata.tmp_patch) Daniel@0: set(udata.tmp_patch(i),'FaceVertexCData',col); Daniel@0: end Daniel@0: Daniel@0: udata.new_marks=[]; Daniel@0: udata.all_marks=[]; Daniel@0: Daniel@0: Daniel@0: if any(strcmp('c_struct',fieldnames(udata))) Daniel@0: udata=rmfield(udata,'c_struct'); Daniel@0: end Daniel@0: Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function key_bdf Daniel@0: Daniel@0: % moves trajectory and pointer lines, when either of Daniel@0: % the keys '>' or '<' is pressed. Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: key=get(gcbo,'CurrentCharacter'); Daniel@0: Daniel@0: % The easiest way to get a new coordinates is to get them from the texts... Daniel@0: % The texts are either '<- x' or 'x ->' Daniel@0: Daniel@0: x=get(udata.text1(1),'String'); Daniel@0: x=str2num(x(4:length(x))); Daniel@0: Daniel@0: if isempty(x) Daniel@0: x=get(udata.text1(1),'String'); Daniel@0: x=str2num(x(1:length(x)-3)); Daniel@0: end Daniel@0: Daniel@0: switch(key) Daniel@0: case '<' Daniel@0: if x ~= 1 Daniel@0: x= x-1; Daniel@0: end Daniel@0: case '>' Daniel@0: if x ~= getfield(get(get(udata.text1(1),'Parent'),'XLim'),{2}) Daniel@0: x = x+1; Daniel@0: end Daniel@0: otherwise Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: set(udata.l,'XData',[x x]); Daniel@0: if ~isempty(udata.fig2) Daniel@0: set(udata.l2,'XData',[x x]); Daniel@0: end Daniel@0: Daniel@0: delete(udata.text1); Daniel@0: delete(udata.text2); Daniel@0: Daniel@0: set_numbers(x); Daniel@0: draw_traj(x); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function click() Daniel@0: Daniel@0: Daniel@0: switch get(gcf,'SelectionType') Daniel@0: case 'open' Daniel@0: return; Daniel@0: case {'normal','alt'} Daniel@0: draw_poly; Daniel@0: case 'extend' Daniel@0: click_node; Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function click_node() Daniel@0: Daniel@0: % takes care of the action, when the middle mouse button is Daniel@0: % pressed (mouse pointer is above some component plane). Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: new_marks=[]; Daniel@0: Daniel@0: old=gcf; Daniel@0: Daniel@0: NEW=0; Daniel@0: AGAIN = 0; Daniel@0: Daniel@0: Daniel@0: coords=get(gca,'CurrentPoint'); Daniel@0: row=round(coords(1,2)); Daniel@0: Daniel@0: if strcmp(udata.lattice,'hexa') & ~mod(row,2) Daniel@0: col = round(coords(1,1) - 0.5); Daniel@0: else Daniel@0: col = round(coords(1,1)); Daniel@0: end Daniel@0: Daniel@0: ind = sub2ind(udata.msize,row,col); Daniel@0: new_marks=find(udata.bmus==ind); Daniel@0: Daniel@0: if strcmp(get(gcbo,'Tag'),'TmpPatch'); Daniel@0: Daniel@0: % if the callback is made via temporary patch object, node is marked Daniel@0: % (node is black) => the mark is to be removed Daniel@0: Daniel@0: node_color = getfield(get(gcbo,'FaceVertexCData'),{ind,[1:3]}); Daniel@0: AGAIN = 1; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: Daniel@0: for i=1:length(udata.tmp_patch) Daniel@0: color = get(udata.tmp_patch(i),'FaceVertexCData'); Daniel@0: if length(size(color)) ~= 2 Daniel@0: color = reshape(color,[size(color,1) 3]); Daniel@0: end Daniel@0: if all(isnan(color(ind,:))) Daniel@0: NEW=1; Daniel@0: color(ind,:)=[0 0 0]; Daniel@0: else Daniel@0: color(ind,:)=[NaN NaN NaN]; Daniel@0: end Daniel@0: set(udata.tmp_patch(i),'FaceVertexCData',color); Daniel@0: end Daniel@0: Daniel@0: set(0,'CurrentFigure',udata.fig1); Daniel@0: Daniel@0: for j=1:length(udata.h) Daniel@0: subplot(udata.h(j)); Daniel@0: if NEW Daniel@0: y=getfield(get(udata.d(j),'YData'),{new_marks}); Daniel@0: udata.d_mark(j).h=[udata.d_mark(j).h;plot(new_marks,y,'Color',[0 0 0],... Daniel@0: 'LineStyle','none',... Daniel@0: 'Marker','o')]; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: Daniel@0: if ~isempty(udata.fig2) Daniel@0: set(0,'CurrentFigure',udata.fig2); Daniel@0: for j=1:length(udata.h2); Daniel@0: subplot(udata.h2(j)); Daniel@0: if NEW Daniel@0: y=getfield(get(udata.d2(j),'YData'),{new_marks}); Daniel@0: udata.d_mark2(j).h=[udata.d_mark2(j).h;plot(new_marks,y,... Daniel@0: 'LineStyle','none',... Daniel@0: 'Color','black',... Daniel@0: 'Marker','o')]; Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: if NEW Daniel@0: udata.new_marks=[udata.new_marks; new_marks]; Daniel@0: end Daniel@0: Daniel@0: if AGAIN Daniel@0: Daniel@0: % find marks from the data that map to the clicked node. if the color Daniel@0: % of the mark(s) is the same as the node's color, remove mark(s), else Daniel@0: % let mark be unchanged. Daniel@0: Daniel@0: for i=1:length(udata.d_mark(1).h) Daniel@0: if all(node_color==get(udata.d_mark(1).h(i),'Color')) Daniel@0: tmp1 = get(udata.d_mark(1).h(i),'XData'); Daniel@0: tmp2 = setdiff(tmp1,new_marks); Daniel@0: if length(tmp1) ~= length(tmp2) Daniel@0: inds=[]; Daniel@0: for j=1:length(tmp2); Daniel@0: inds=[inds find(tmp2(j)==tmp1)]; Daniel@0: end Daniel@0: for j=1:length(udata.d_mark) Daniel@0: ydata=getfield(get(udata.d_mark(j).h(i),'YData'),{inds}); Daniel@0: set(udata.d_mark(j).h(i),'XData',tmp2,'YData',ydata); Daniel@0: end Daniel@0: if ~isempty(udata.fig2) Daniel@0: for j=1:length(udata.d_mark2) Daniel@0: ydata=getfield(get(udata.d_mark2(j).h(i),'YData'),{inds}); Daniel@0: set(udata.d_mark2(j).h(i),'XData',tmp2,'YData',ydata); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: udata.new_marks=setdiff(udata.new_marks, new_marks); Daniel@0: udata.all_marks=setdiff(udata.all_marks,new_marks); Daniel@0: end Daniel@0: Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: set(0,'CurrentFigure',old); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function draw_poly() Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: if isempty(udata.poly.x) Daniel@0: if strcmp(get(gcf,'SelectionType'),'alt') Daniel@0: return; Daniel@0: end Daniel@0: udata.poly.THIS = gca; Daniel@0: end Daniel@0: Daniel@0: % 'THIS' indicates what was the axes where the polygon was meant to Daniel@0: % drawn. It is not possible to add points, that lie in another axes, to the Daniel@0: % polygon. Daniel@0: Daniel@0: Daniel@0: if gca ~= udata.poly.THIS Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: coords(1,1) = getfield(get(gca,'CurrentPoint'),{3}); Daniel@0: coords(1,2) = getfield(get(gca,'CurrentPoint'),{1}); Daniel@0: Daniel@0: udata.poly.x=cat(1,udata.poly.x,coords(2)); Daniel@0: udata.poly.y=cat(1,udata.poly.y,coords(1)); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: % remove old 'polygon' from axis Daniel@0: Daniel@0: delete(udata.poly.h); Daniel@0: Daniel@0: Daniel@0: switch get(gcf,'SelectionType') Daniel@0: case 'normal' Daniel@0: Daniel@0: % add point to the 'polygon' and draw it Daniel@0: Daniel@0: for i=1:length(udata.a_h) Daniel@0: subplot(udata.a_h(i)); Daniel@0: hold on; Daniel@0: udata.poly.h(i) = plot(udata.poly.x,udata.poly.y,'black',... Daniel@0: 'EraseMode','xor',... Daniel@0: 'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],''click'')',... Daniel@0: 'LineWidth',2); Daniel@0: end Daniel@0: case 'alt' Daniel@0: Daniel@0: % The polygon is ready. Daniel@0: Daniel@0: Daniel@0: udata.poly.x=cat(1,udata.poly.x,udata.poly.x(1)); Daniel@0: udata.poly.y=cat(1,udata.poly.y,udata.poly.y(1)); Daniel@0: Daniel@0: for i=1:length(udata.a_h) Daniel@0: subplot(udata.a_h(i)); Daniel@0: udata.poly.h(i) = plot(udata.poly.x,udata.poly.y,'black',... Daniel@0: 'EraseMode','xor',... Daniel@0: 'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],''click'')',... Daniel@0: 'LineWidth',2); Daniel@0: end Daniel@0: Daniel@0: tmp=sort(repmat((1:udata.msize(1))',udata.msize(2),1)); Daniel@0: tmp(:,2)=repmat((1:udata.msize(2))',udata.msize(1),1); Daniel@0: tmp2=tmp; Daniel@0: if strcmp(udata.lattice,'hexa'); Daniel@0: t=find(~rem(tmp(:,1),2)); Daniel@0: tmp(t,2)=tmp(t,2)+0.5; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: % find the nodes that lie inside polygon and change coordinates to Daniel@0: % linear indices. Daniel@0: Daniel@0: in = find(inpolygon(tmp(:,2),tmp(:,1),udata.poly.x,udata.poly.y)); Daniel@0: in = sub2ind(udata.msize,tmp2(in,1),tmp2(in,2)); Daniel@0: Daniel@0: colors=get(udata.tmp_patch(1),'FaceVertexCData'); Daniel@0: colors=reshape(colors,[size(colors,1) 3]); Daniel@0: tmp=ones(length(in),1); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: % set the color of the nodes just selected, black. Daniel@0: Daniel@0: colors(in,:)=tmp*[0 0 0]; Daniel@0: set(udata.tmp_patch,'FaceVertexCData',colors); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: % find the points mapping to the nodes from data Daniel@0: Daniel@0: inds = []; Daniel@0: for i=1:length(in) Daniel@0: inds=[inds;find(in(i) == udata.bmus)]; Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%% Daniel@0: % plot marks to data Daniel@0: Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: plot2data(inds); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: udata.new_marks=union(udata.new_marks,inds); Daniel@0: delete(udata.poly.h); Daniel@0: udata.poly.h=[]; Daniel@0: udata.poly.x=[]; Daniel@0: udata.poly.y=[]; Daniel@0: udata.poly.THIS=[]; Daniel@0: end Daniel@0: Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function save_data() Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: data.points=[]; Daniel@0: data.nodes=[]; Daniel@0: k=1; Daniel@0: Daniel@0: for i=1:length(udata.d_mark(1).h) Daniel@0: data.points(i).inds=get(udata.d_mark(1).h(i),'XData'); Daniel@0: data.points(i).color=get(udata.d_mark(1).h(i),'Color'); Daniel@0: end Daniel@0: Daniel@0: color=get(udata.tmp_patch(1),'FaceVertexCData'); Daniel@0: color=reshape(color,[size(color,1) 3]); Daniel@0: Daniel@0: for i=1:size(color,1) Daniel@0: if all(~isnan(color(i,:))) Daniel@0: tmp.ind=i; Daniel@0: tmp.color=color(i,:); Daniel@0: data.nodes(k)=tmp; Daniel@0: k=k+1; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: answer=inputdlg('Enter the name of the output variable:','',1); Daniel@0: Daniel@0: if isempty(answer) | isempty(answer{1}) Daniel@0: msgbox('Output is not set to workspace.'); Daniel@0: return; Daniel@0: else Daniel@0: assignin('base',answer{1},data); Daniel@0: disp(sprintf('Struct is set to the workspace as ''%s''.',answer{1})); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function load_data() Daniel@0: Daniel@0: answer = inputdlg('Enter the name of the struct to be loaded:','',1); Daniel@0: Daniel@0: if isempty(answer) | isempty(answer{1}) Daniel@0: msgbox('Data is not loaded.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: data=evalin('base',answer{1}); Daniel@0: Daniel@0: if ~isstruct(data) Daniel@0: errordlg('Input variable must be a struct.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: tmp1 = fieldnames(data); Daniel@0: tmp2 = {'nodes','points'}; Daniel@0: Daniel@0: for i=1:length(tmp1) Daniel@0: for j=1:length(tmp2); Daniel@0: if ~any(strcmp(tmp2{j},tmp1)) Daniel@0: errordlg('Wrong type of struct.'); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: if ~isempty(data.points) Daniel@0: tmp1=fieldnames(data.points(1)); Daniel@0: end Daniel@0: if ~isempty(data.nodes) Daniel@0: tmp2=fieldnames(data.nodes(1)); Daniel@0: end Daniel@0: Daniel@0: for i=1:length(tmp1) Daniel@0: if ~any(strcmp(tmp1{i},{'inds','color'})) Daniel@0: errordlg('Wrong type of struct.'); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: for i=1:length(tmp2) Daniel@0: if ~any(strcmp(tmp2{i},{'ind','color'})) Daniel@0: errordlg('Wrong type of struct.'); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: clear_markers; Daniel@0: remove_traj; Daniel@0: Daniel@0: old = gcf; Daniel@0: Daniel@0: for i=1:length(data.points) Daniel@0: for j=1:length(udata.h); Daniel@0: set(0,'CurrentFigure',udata.fig1); Daniel@0: subplot(udata.h(j)); Daniel@0: ydata=getfield(get(udata.d(j),'YData'),{data.points(i).inds}); Daniel@0: udata.d_mark(j).h=[udata.d_mark(j).h;... Daniel@0: plot(data.points(i).inds,ydata,... Daniel@0: 'Color',data.points(i).color,... Daniel@0: 'LineStyle','none',... Daniel@0: 'Marker','o',... Daniel@0: 'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],''line_down'')')]; Daniel@0: if all(data.points(i).color == [0 0 0]) Daniel@0: udata.new_marks=unique([udata.new_marks; (data.points(i).inds)']); Daniel@0: else Daniel@0: udata.all_marks=unique([udata.all_marks; (data.points(i).inds)']); Daniel@0: end Daniel@0: end Daniel@0: if ~isempty(udata.fig2) Daniel@0: set(0,'CurrentFigure',udata.fig2); Daniel@0: for j=1:length(udata.h2) Daniel@0: subplot(udata.h2(j)); Daniel@0: ydata=getfield(get(udata.d2(j),'YData'),{data.points(i).inds}); Daniel@0: udata.d_mark2(j).h=[udata.d_mark2(j).h;... Daniel@0: plot(data.points(i).inds,ydata,... Daniel@0: 'Color',data.points(i).color,... Daniel@0: 'LineStyle','none',... Daniel@0: 'Marker','o',... Daniel@0: 'ButtonDownFcn',... Daniel@0: 'vis_trajgui([],''line_down'')')]; Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: Daniel@0: set(0,'CurrentFigure',udata.sM_h); Daniel@0: color=get(udata.tmp_patch(1),'FaceVertexCData'); Daniel@0: color=reshape(color,[size(color,1) 3]); Daniel@0: for i=1:length(data.nodes) Daniel@0: color(data.nodes(i).ind,:)=data.nodes(i).color; Daniel@0: end Daniel@0: for i=1:length(udata.tmp_patch); Daniel@0: set(udata.tmp_patch(i),'FaceVertexCData',color); Daniel@0: end Daniel@0: Daniel@0: set(0,'CurrentFigure',old); Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function fuzzy_traj(trajStruct,arg); Daniel@0: %function fuzzy_traj(sM_h,sM,sD,interval,arg) Daniel@0: Daniel@0: Daniel@0: if isempty(arg) Daniel@0: Daniel@0: if strcmp(trajStruct.lattice,'hexa') Daniel@0: udata.lattice='hexa'; Daniel@0: udata.form=vis_patch('hexa'); Daniel@0: else Daniel@0: data.lattice='rect'; Daniel@0: udata.form=vis_patch('rect'); Daniel@0: end Daniel@0: Daniel@0: % interval=[1 size(trajStruct.primary_data,1)]; Daniel@0: Daniel@0: l=size(udata.form,1); Daniel@0: dim = size(trajStruct.primary_data,2); Daniel@0: udata.a_h=[findobj(get(trajStruct.figure,'Children'),'Tag','Uplane');... Daniel@0: findobj(get(trajStruct.figure,'Children'),'Tag','Cplane')]; Daniel@0: Daniel@0: udata.sM_h=trajStruct.figure; Daniel@0: udata.msize=trajStruct.msize; Daniel@0: Daniel@0: %%%%%%%%%%%%%%% Daniel@0: % Daniel@0: % constructing patch that is drawn above every plane in map Daniel@0: % Daniel@0: Daniel@0: nx = repmat(udata.form(:,1),1,prod(udata.msize)); Daniel@0: ny = repmat(udata.form(:,2),1,prod(udata.msize)); Daniel@0: Daniel@0: x_c=reshape(repmat(1:udata.msize(2),l*udata.msize(1),1),l,prod(udata.msize)); Daniel@0: y_c=repmat(repmat(1:udata.msize(1),l,1),1,udata.msize(2)); Daniel@0: Daniel@0: if strcmp(udata.lattice,'hexa') Daniel@0: t = find(~rem(y_c(1,:),2)); Daniel@0: x_c(:,t)=x_c(:,t)+.5; Daniel@0: end Daniel@0: Daniel@0: x_c=x_c+nx; Daniel@0: y_c=y_c+ny; Daniel@0: Daniel@0: udata.orig_c=ones(prod(udata.msize),1)*[NaN NaN NaN]; Daniel@0: colors=reshape(udata.orig_c,[1 size(udata.orig_c,1) 3]); Daniel@0: set(0,'CurrentFigure',trajStruct.figure); Daniel@0: Daniel@0: %%%%%%%%% Daniel@0: % drawing Daniel@0: Daniel@0: for i=1:length(udata.a_h); Daniel@0: subplot(udata.a_h(i)); Daniel@0: v=caxis; Daniel@0: udata.patch_h(i) =patch(x_c,y_c,colors,'EdgeColor','none'); Daniel@0: caxis(v); Daniel@0: end Daniel@0: Daniel@0: Daniel@0: udata.orig_x=get(udata.patch_h(1),'XData'); Daniel@0: udata.orig_y=get(udata.patch_h(1),'YData'); Daniel@0: Daniel@0: % if interval(1) < 1 | interval(2) > size(trajStruct.primary_data,1) Daniel@0: % error('Invalid argument ''interval''.'); Daniel@0: % end Daniel@0: Daniel@0: x=1:size(trajStruct.primary_data,1); Daniel@0: udata.fig1=figure; Daniel@0: set(udata.fig1,'KeyPressFcn',... Daniel@0: 'vis_trajgui([],''move_fuzzy'')'); Daniel@0: for i=1:size(trajStruct.primary_data,2) Daniel@0: subplot(size(trajStruct.primary_data,2),1,i); Daniel@0: udata.h(i)=gca; Daniel@0: set(udata.h(1),'XTick',[]); Daniel@0: udata.d(i)=plot(x,trajStruct.primary_data(:,i)); Daniel@0: l_x=1; Daniel@0: lims(1) = round(min(trajStruct.primary_data(:,i))); Daniel@0: lims(2) = round(max(trajStruct.primary_data(:,i))); Daniel@0: udata.l(i) = line([l_x l_x],lims,'Color','red','EraseMode','xor'); Daniel@0: end Daniel@0: Daniel@0: udata.l_x = l_x; Daniel@0: udata.interval=[1 size(trajStruct.bmus,2)]; Daniel@0: Daniel@0: tmp.fig1=udata.fig1; Daniel@0: % [K,P] = estimate_kernels(sM,sD); Daniel@0: % udata.K=K; Daniel@0: % udata.P=P; Daniel@0: % udata.codebook=sM.codebook; Daniel@0: % udata.data=sD.data; Daniel@0: udata.bmus=trajStruct.bmus; Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: set(trajStruct.figure,'UserData',tmp); Daniel@0: draw_fuzzy(l_x); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: move_fuzzy; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function draw_fuzzy(x) Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: inds = find(udata.bmus(:,x)); Daniel@0: [row col] = ind2sub(udata.msize,inds); Daniel@0: if strcmp(udata.lattice,'hexa') Daniel@0: t=find(~mod(row,2)); Daniel@0: col(t)=col(t)+0.5; Daniel@0: end Daniel@0: Daniel@0: color=udata.orig_c; Daniel@0: color=reshape(color,[size(color,1) 3]); Daniel@0: xdata=udata.orig_x; Daniel@0: ydata=udata.orig_y; Daniel@0: tmp= ones(size(xdata(:,1),1),1)*udata.bmus(inds,x)'; Daniel@0: color(inds,:) = ones(length(inds),1)*[0 0 0]; Daniel@0: xdata(:,inds) = udata.form(:,1)*ones(1,length(inds)).*tmp+ones(6,1)*col'; Daniel@0: ydata(:,inds) = udata.form(:,2)*ones(1,length(inds)).*tmp+ones(6,1)*row'; Daniel@0: Daniel@0: set(udata.patch_h,'FaceVertexCData',color,'XData',xdata,'YData',ydata); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function move_fuzzy Daniel@0: Daniel@0: % moves pointer lines and draws fuzzy response. Daniel@0: Daniel@0: udata=get(gcf,'UserData'); Daniel@0: udata=get(udata.fig1,'UserData'); Daniel@0: Daniel@0: switch get(gcf,'CurrentCharacter'); Daniel@0: case {'<','>'} Daniel@0: key = get(gcf,'CurrentCharacter'); Daniel@0: if key == '>' Daniel@0: if udata.l_x + 1 > udata.interval(2) Daniel@0: return; Daniel@0: end Daniel@0: l_x = udata.l_x + 1; Daniel@0: else Daniel@0: if udata.l_x - 1 < udata.interval(1) Daniel@0: return; Daniel@0: end Daniel@0: l_x = udata.l_x - 1; Daniel@0: end Daniel@0: draw_fuzzy(l_x); Daniel@0: set(udata.l,'XData',[l_x l_x]); Daniel@0: udata.l_x=l_x; Daniel@0: set(udata.fig1,'UserData',udata); Daniel@0: otherwise Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: Daniel@0: