Guest User

GUI Dzhamshed

a guest
Aug 7th, 2012
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.38 KB | None | 0 0
  1. function varargout = untitled(varargin)
  2. % UNTITLED M-file for untitled.fig
  3. % UNTITLED, by itself, creates a new UNTITLED or raises the existing
  4. % singleton*.
  5. %
  6. % H = UNTITLED returns the handle to a new UNTITLED or the handle to
  7. % the existing singleton*.
  8. %
  9. % UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in UNTITLED.M with the given input arguments.
  11. %
  12. % UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before untitled_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to untitled_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22.  
  23. % Edit the above text to modify the response to help untitled
  24.  
  25. % Last Modified by GUIDE v2.5 07-Aug-2012 11:58:09
  26.  
  27. % Begin initialization code - DO NOT EDIT
  28. gui_Singleton = 1;
  29. gui_State = struct('gui_Name', mfilename, ...
  30. 'gui_Singleton', gui_Singleton, ...
  31. 'gui_OpeningFcn', @untitled_OpeningFcn, ...
  32. 'gui_OutputFcn', @untitled_OutputFcn, ...
  33. 'gui_LayoutFcn', [] , ...
  34. 'gui_Callback', []);
  35. if nargin && ischar(varargin{1})
  36. gui_State.gui_Callback = str2func(varargin{1});
  37. end
  38.  
  39. if nargout
  40. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  41. else
  42. gui_mainfcn(gui_State, varargin{:});
  43. end
  44. % End initialization code - DO NOT EDIT
  45.  
  46.  
  47. % --- Executes just before untitled is made visible.
  48. function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
  49. % This function has no output args, see OutputFcn.
  50. % hObject handle to figure
  51. % eventdata reserved - to be defined in a future version of MATLAB
  52. % handles structure with handles and user data (see GUIDATA)
  53. % varargin command line arguments to untitled (see VARARGIN)
  54.  
  55. % Choose default command line output for untitled
  56. handles.output = hObject;
  57.  
  58. % Update handles structure
  59. guidata(hObject, handles);
  60.  
  61. % UIWAIT makes untitled wait for user response (see UIRESUME)
  62. % uiwait(handles.figure1);
  63.  
  64.  
  65. % --- Outputs from this function are returned to the command line.
  66. function varargout = untitled_OutputFcn(hObject, eventdata, handles)
  67. % varargout cell array for returning output args (see VARARGOUT);
  68. % hObject handle to figure
  69. % eventdata reserved - to be defined in a future version of MATLAB
  70. % handles structure with handles and user data (see GUIDATA)
  71.  
  72. % Get default command line output from handles structure
  73. varargout{1} = handles.output;
  74.  
  75.  
  76. % --- Executes on selection change in popupmenuY.
  77. function popupmenuY_Callback(hObject, eventdata, handles)
  78. % hObject handle to popupmenuY (see GCBO)
  79. % eventdata reserved - to be defined in a future version of MATLAB
  80. % handles structure with handles and user data (see GUIDATA)
  81.  
  82. % Hints: contents = get(hObject,'String') returns popupmenuY contents as cell array
  83. % contents{get(hObject,'Value')} returns selected item from popupmenuY
  84.  
  85.  
  86. % --- Executes during object creation, after setting all properties.
  87. function popupmenuY_CreateFcn(hObject, eventdata, handles)
  88. % hObject handle to popupmenuY (see GCBO)
  89. % eventdata reserved - to be defined in a future version of MATLAB
  90. % handles empty - handles not created until after all CreateFcns called
  91.  
  92. % Hint: popupmenu controls usually have a white background on Windows.
  93. % See ISPC and COMPUTER.
  94. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  95. set(hObject,'BackgroundColor','white');
  96. end
  97.  
  98.  
  99. % --- Executes on selection change in popupmenuX.
  100. function popupmenuX_Callback(hObject, eventdata, handles)
  101. % hObject handle to popupmenuX (see GCBO)
  102. % eventdata reserved - to be defined in a future version of MATLAB
  103. % handles structure with handles and user data (see GUIDATA)
  104.  
  105. % Hints: contents = get(hObject,'String') returns popupmenuX contents as cell array
  106. % contents{get(hObject,'Value')} returns selected item from popupmenuX
  107.  
  108.  
  109. % --- Executes during object creation, after setting all properties.
  110. function popupmenuX_CreateFcn(hObject, eventdata, handles)
  111. % hObject handle to popupmenuX (see GCBO)
  112. % eventdata reserved - to be defined in a future version of MATLAB
  113. % handles empty - handles not created until after all CreateFcns called
  114.  
  115. % Hint: popupmenu controls usually have a white background on Windows.
  116. % See ISPC and COMPUTER.
  117. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  118. set(hObject,'BackgroundColor','white');
  119. end
  120.  
  121.  
  122. % --- Executes on button press in pushbuttonLoadXLS.
  123. function pushbuttonLoadXLS_Callback(hObject, eventdata, handles)
  124. handles.fileName=uigetfile('*.xls')
  125. guidata(hObject, handles)
  126. setPopupmenuString(handles.popupmenuX, eventdata, handles)
  127. setPopupmenuString(handles.popupmenuY, eventdata, handles)
  128. set (handles. popupmenuX, 'callback','mainGUI(''updateAxes'',gcbo,[],guidata(gcbo))')
  129. set (handles. popupmenuY, 'callback','mainGUI(''updateAxes'',gcbo,[],guidata(gcbo))')
  130. function setPopupmenuString(hObject, eventdata, handles)
  131. fileName=handles.fileName;
  132. [numbers,colNames]=xlsread(fileName);
  133. set(hObject,'string',colNames);
  134. % hObject handle to pushbuttonLoadXLS (see GCBO)
  135. % eventdata reserved - to be defined in a future version of MATLAB
  136. % handles structure with handles and user data (see GUIDATA)
  137. function [x,y] = readExcelColumns (fileName, xColNum, yColNum)
  138. a= xlsread(fileName);
  139. x=a(:,xColNum);
  140. y=a(:,yColNum)
  141.  
  142. function updateAxes (hObject, eventdata, handles)
  143. xColNum = get(handles.popupmenuX, 'value');
  144. yColNum = get(handles.popupmenuY, 'value');
  145. fileName=handles.fileName;
  146. inf = 1;
  147. for k=1:1000
  148. [x,y] = readExcelColumns (fileName, xColNum, yColNum)
  149. plot (handles.axes1,x,y)
  150. pause (10);
  151. if inf==0
  152. break;
  153. end
  154. end
  155.  
  156.  
  157.  
  158. % --- Executes on button press in pushbuttonSTOP.
  159. function pushbuttonSTOP_Callback(hObject, eventdata, handles)
  160. inf = 0;
  161.  
  162. % hObject handle to pushbuttonSTOP (see GCBO)
  163. % eventdata reserved - to be defined in a future version of MATLAB
  164. % handles structure with handles and user data (see GUIDATA)
Advertisement
Add Comment
Please, Sign In to add comment