keymasterviriya1150

matlab

Feb 8th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 4.20 KB | None | 0 0
  1. function varargout = GUI(varargin)
  2.  
  3. % Begin initialization code - DO NOT EDIT
  4. gui_Singleton = 1;
  5. gui_State = struct('gui_Name',       mfilename, ...
  6.                    'gui_Singleton',  gui_Singleton, ...
  7.                    'gui_OpeningFcn', @GUI_OpeningFcn, ...
  8.                    'gui_OutputFcn',  @GUI_OutputFcn, ...
  9.                    'gui_LayoutFcn',  [] , ...
  10.                    'gui_Callback',   []);
  11. if nargin && ischar(varargin{1})
  12.     gui_State.gui_Callback = str2func(varargin{1});
  13. end
  14.  
  15. if nargout
  16.     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  17. else
  18.     gui_mainfcn(gui_State, varargin{:});
  19. end
  20. % End initialization code - DO NOT EDIT
  21.  
  22.  
  23. % --- Executes just before GUI is made visible.
  24. function GUI_OpeningFcn(hObject, eventdata, handles, varargin)
  25.  
  26. % Choose default command line output for GUI
  27. handles.output = hObject;
  28. % Update handles structure
  29. guidata(hObject, handles);
  30.  
  31. % UIWAIT makes GUI wait for user response (see UIRESUME)
  32. % uiwait(handles.figure1);
  33.  
  34.  
  35. % --- Outputs from this function are returned to the command line.
  36. function varargout = GUI_OutputFcn(hObject, eventdata, handles)
  37.  
  38.  
  39. % Get default command line output from handles structure
  40. varargout{1} = handles.output;
  41.  
  42.  
  43. % --- Executes on slider movement.
  44. function slider_Callback(hObject, eventdata, handles)
  45. % hObject    handle to slider (see GCBO)
  46. % eventdata  reserved - to be defined in a future version of MATLAB
  47. % handles    structure with handles and user data (see GUIDATA)
  48. slideVal = get(handles.slider,'Value');
  49. assignin('base','slideVal',slideVal);
  50. set(handles.amp,'String',num2str(slideVal));
  51.  
  52.  
  53. % Hints: get(hObject,'Value') returns position of slider
  54. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  55.  
  56.  
  57. % --- Executes during object creation, after setting all properties.
  58. function slider_CreateFcn(hObject, eventdata, handles)
  59.  
  60. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  61.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  62. end
  63.  
  64.  
  65. function period_Callback(hObject, eventdata, handles)
  66.  
  67.  
  68. % --- Executes during object creation, after setting all properties.
  69. function period_CreateFcn(hObject, eventdata, handles)
  70.  
  71. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  72.     set(hObject,'BackgroundColor','white');
  73. end
  74.  
  75.  
  76.  
  77. function amp_Callback(hObject, eventdata, handles)
  78.  
  79. function amp_CreateFcn(hObject, eventdata, handles)
  80.  
  81. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  82.     set(hObject,'BackgroundColor','white');
  83. end
  84.  
  85.  
  86. % --- Executes on button press in plot.
  87. function plot_Callback(hObject, eventdata, handles)
  88.  
  89.  
  90. amplitude = str2num(get(handles.amp,'String'));
  91. period = str2num(get(handles.period,'String'));
  92. a = get(handles.func,'value');
  93. n = [0:0.01:10*pi];
  94. if (a == 1)
  95.     fig = plot(amplitude*sin(period*n));
  96. elseif (a==2)
  97.     fig=plot(amplitude*cos(period*n));
  98. else
  99.     fig=plot(amplitude*tan(period*n));
  100. end
  101. axes(handles.axes1);
  102.  
  103. h = impoly();
  104. nodes = getPosition(h);
  105. %position = wait(h)
  106. nodes
  107. % now you go and position the polygon, control returns once you've 'finsished' with it '
  108. guidata(hObject,handles)
  109.  
  110.  
  111.  
  112.  
  113.  
  114. % --- Executes during object creation, after setting all properties.
  115. function axes1_CreateFcn(hObject, eventdata, handles)
  116.  
  117.  
  118.  
  119.  
  120. % --- Executes on selection change in func.
  121. function func_Callback(hObject, eventdata, handles)
  122.  
  123.  
  124. % --- Executes during object creation, after setting all properties.
  125. function func_CreateFcn(hObject, eventdata, handles)
  126.  
  127. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  128.     set(hObject,'BackgroundColor','white');
  129. end
  130.  
  131.  
  132. % --- Executes on slider movement.
  133. function slider2_Callback(hObject, eventdata, handles)
  134.  
  135. slideVal2 = get(handles.slider2,'Value');
  136. assignin('base','slideVal2',slideVal2);
  137. set(handles.period,'String',num2str(slideVal2));
  138.  
  139.  
  140.  
  141. function slider2_CreateFcn(hObject, eventdata, handles)
  142.  
  143.  
  144. % Hint: slider controls usually have a light gray background.
  145. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  146.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  147. end
Advertisement
Add Comment
Please, Sign In to add comment