Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.27 KB | None | 0 0
  1. function Call_Click(~,~,Num)
  2.         key = get(gcf, 'SelectionType');
  3.         if isequal(key,'alt')
  4.          h=get(Slider,'value');
  5.          if flag==1
  6.             Prev_Data_1=Prev_Data_1*h;
  7.             Plot(Prev_Data_1);  
  8.         elseif flag==3
  9.             Prev_Data_1=Energy2(Data,c1);
  10.             Plot(Prev_Data_1);
  11.          end          
  12.         elseif isequal (key,'normal')
  13.             if f==1
  14.                 set(findall(0,'tag',int2str(Num2)),'color','b');
  15.                 trace=Data(:,Num);
  16.                 set(findall(0,'tag',int2str(Num)),'color','r');
  17.                 Num2=Num;
  18.             elseif f==2
  19.                % delete (findall(0,'tag',['peak' int2str(Num)]));
  20.                 pos=get(Axes,'CurrentPoint');
  21.                 p(1:2,1)=pos(1,1);
  22.                 peak(Num)=p(1,1);
  23.                 y(1,1)=Num-1/4;
  24.                 y(2,1)=Num+1/4;
  25.                 line('tag',['peak' int2str(Num)],'Parent',Axes,'XData',p(:,1),'YData',y,...
  26.                     'color','r','linewidth',2);
  27.             elseif f==3
  28.                 z=1;
  29.                 pos=get(Axes,'CurrentPoint');
  30.                 p(1:2,1)=pos(1,1);
  31.                 peak(Num)=p(1,1);
  32.                 y(1,1)=Num-1/4;
  33.                 y(2,1)=Num+1/4;
  34.                 line('tag',['peak' int2str(Num)],'Parent',Axes,'XData',p(:,1),'YData',y,...
  35.                     'color','r','linewidth',2);        
  36.             elseif f==4
  37.                 waitforbuttonpress;
  38.                 point1 = get(Axes,'CurrentPoint');    % button down detected
  39.                 finalRect = rbbox;                 % return figure units
  40.                 point2 = get(Axes,'CurrentPoint');    % button up detected
  41.                 point1 = point1(1,1:2);            % extract x and y
  42.                 point2 = point2(1,1:2);
  43.                 p1 = min(point1,point2);           % calculate locations
  44.                 offset = abs(point1-point2);       % and dimensions
  45.                 X = [p1(1) p1(1)+offset(1) p1(1)+offset(1) p1(1) p1(1)];
  46.                 Y = [p1(2) p1(2) p1(2)+offset(2) p1(2)+offset(2) p1(2)];
  47.                 hold on
  48.                 axis (Axes,[min(X) max(X) min(Y) max(Y)]);
  49.                 plot(X,Y)                          % redraw in dataspace units
  50.                
  51.             end
  52.         end
  53.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement