Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.89 KB | None | 0 0
  1. function geodata
  2. % SIMPLE_GUI2 Select a data set from the pop-up menu and display
  3. f = figure('Position',[400,400,600,500]);
  4. h = [];
  5. % Construct the components.
  6. h(1) = uicontrol('Style','popupmenu',...
  7.     'String',{'Peaks','Membrane','Sinc'},...
  8.     'Position',[500,20,100,25],...
  9.     'Callback',@popup_menu_Callback);
  10.  
  11. h(2) = axes('Units','pixels','Position',[50,30,355,355]);
  12. h(3) = uicontrol('Style','pushbutton',...
  13.     'String','Rotate',...
  14.     'Position',[500,60,100,25],...
  15.     'Callback',@rotate);
  16. % Assure resize automatically.
  17. f.Units = 'normalized';    set(h, 'Units', 'normalized');
  18. set(h, 'FontSize', 12);
  19. % Generate the data to plot.
  20. peaks_data = peaks(35);
  21. membrane_data = membrane;
  22. [x,y] = meshgrid(-8:.5:8);
  23. r = sqrt(x.^2+y.^2) + eps;
  24. sinc_data = sin(r)./r;
  25. % Create a plot in the axes.
  26. current_data = peaks_data;
  27. surf(current_data);
  28. %view([-90 0]); % forran
  29. %view([0 0]); % fra siden
  30. %view([-90 90]); % top
  31.  
  32. %  Pop-up menu callback. Read the pop-up menu Value property to
  33.     function popup_menu_Callback(source,eventdata)
  34.         % Determine the selected data set.
  35.         str = get(source, 'String');
  36.         val = get(source,'Value');
  37.        
  38.         % Set current data to the selected data set.
  39.         switch str{val}
  40.             case 'Peaks'
  41.                 % User selects Peaks.
  42.                 current_data = peaks_data;
  43.             case 'Membrane'
  44.                 current_data = membrane_data;
  45.                
  46.             case 'Sinc'
  47.                 current_data = sinc_data;
  48.         end
  49.        
  50.         surf(current_data);
  51.         % set view
  52.     end
  53.     function rotate(source,eventdata)
  54.         %view([-90 90])
  55.         %direction = [0 0 1];      
  56.         %rotate(f, direction, 1)
  57.         for z = -400:5:400    
  58.             campos([0,0,z])    
  59.             camroll(1);    
  60.             drawnow    
  61.             pause(0.05);
  62.         end
  63.     end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement