Guest User

Untitled

a guest
Apr 30th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 7.50 KB | None | 0 0
  1. function varargout = projekt(varargin)
  2. % PROJEKT MATLAB code for projekt.fig
  3. %      PROJEKT, by itself, creates a new PROJEKT or raises the existing
  4. %      singleton*.
  5. %
  6. %      H = PROJEKT returns the handle to a new PROJEKT or the handle to
  7. %      the existing singleton*.
  8. %
  9. %      PROJEKT('CALLBACK',hObject,eventData,handles,...) calls the local
  10. %      function named CALLBACK in PROJEKT.M with the given input arguments.
  11. %
  12. %      PROJEKT('Property','Value',...) creates a new PROJEKT or raises the
  13. %      existing singleton*.  Starting from the left, property value pairs are
  14. %      applied to the GUI before projekt_OpeningFcn gets called.  An
  15. %      unrecognized property name or invalid value makes property application
  16. %      stop.  All inputs are passed to projekt_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 projekt
  24.  
  25. % Last Modified by GUIDE v2.5 30-Apr-2013 20:14:16
  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', @projekt_OpeningFcn, ...
  32.                    'gui_OutputFcn',  @projekt_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 projekt is made visible.
  48. function projekt_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 projekt (see VARARGIN)
  54.  
  55. % Choose default command line output for projekt
  56. handles.output = hObject;
  57.  
  58. % Update handles structure
  59. guidata(hObject, handles);
  60.  
  61. % UIWAIT makes projekt 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 = projekt_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.  
  77. function funkcja_Callback(hObject, eventdata, handles)
  78. % hObject    handle to funkcja (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: get(hObject,'String') returns contents of funkcja as text
  83. %        str2double(get(hObject,'String')) returns contents of funkcja as a double
  84.  
  85.  
  86. % --- Executes during object creation, after setting all properties.
  87. function funkcja_CreateFcn(hObject, eventdata, handles)
  88. % hObject    handle to funkcja (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: edit 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 button press in rysuj.
  100. function rysuj_Callback(hObject, eventdata, handles)
  101.  
  102. fun=str2func(['@(x) ' get(handles.funkcja,'String')]);
  103. A=str2num(get(handles.a,'String'));
  104. B=str2num(get(handles.b,'String'));
  105. N=str2num(get(handles.n,'String'));
  106. set(handles.QUADval,'String',num2str(quad(fun,A,B),'%.4f'))
  107.  
  108. for i=1:10:N
  109. uplowH(fun,A,B,i,hObject);
  110. pause(1)
  111. end
  112.  
  113.  
  114.  
  115.  
  116. % hObject    handle to rysuj (see GCBO)
  117. % eventdata  reserved - to be defined in a future version of MATLAB
  118. % handles    structure with handles and user data (see GUIDATA)
  119.  
  120.  
  121.  
  122. function a_Callback(hObject, eventdata, handles)
  123. % hObject    handle to a (see GCBO)
  124. % eventdata  reserved - to be defined in a future version of MATLAB
  125. % handles    structure with handles and user data (see GUIDATA)
  126.  
  127. % Hints: get(hObject,'String') returns contents of a as text
  128. %        str2double(get(hObject,'String')) returns contents of a as a double
  129.  
  130.  
  131. % --- Executes during object creation, after setting all properties.
  132. function a_CreateFcn(hObject, eventdata, handles)
  133. % hObject    handle to a (see GCBO)
  134. % eventdata  reserved - to be defined in a future version of MATLAB
  135. % handles    empty - handles not created until after all CreateFcns called
  136.  
  137. % Hint: edit controls usually have a white background on Windows.
  138. %       See ISPC and COMPUTER.
  139. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  140.     set(hObject,'BackgroundColor','white');
  141. end
  142.  
  143.  
  144.  
  145. function b_Callback(hObject, eventdata, handles)
  146. % hObject    handle to b (see GCBO)
  147. % eventdata  reserved - to be defined in a future version of MATLAB
  148. % handles    structure with handles and user data (see GUIDATA)
  149.  
  150. % Hints: get(hObject,'String') returns contents of b as text
  151. %        str2double(get(hObject,'String')) returns contents of b as a double
  152.  
  153.  
  154. % --- Executes during object creation, after setting all properties.
  155. function b_CreateFcn(hObject, eventdata, handles)
  156. % hObject    handle to b (see GCBO)
  157. % eventdata  reserved - to be defined in a future version of MATLAB
  158. % handles    empty - handles not created until after all CreateFcns called
  159.  
  160. % Hint: edit controls usually have a white background on Windows.
  161. %       See ISPC and COMPUTER.
  162. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  163.     set(hObject,'BackgroundColor','white');
  164. end
  165.  
  166.  
  167.  
  168. function n_Callback(hObject, eventdata, handles)
  169. % hObject    handle to n (see GCBO)
  170. % eventdata  reserved - to be defined in a future version of MATLAB
  171. % handles    structure with handles and user data (see GUIDATA)
  172.  
  173. % Hints: get(hObject,'String') returns contents of n as text
  174. %        str2double(get(hObject,'String')) returns contents of n as a double
  175.  
  176.  
  177. % --- Executes during object creation, after setting all properties.
  178. function n_CreateFcn(hObject, eventdata, handles)
  179. % hObject    handle to n (see GCBO)
  180. % eventdata  reserved - to be defined in a future version of MATLAB
  181. % handles    empty - handles not created until after all CreateFcns called
  182.  
  183. % Hint: edit controls usually have a white background on Windows.
  184. %       See ISPC and COMPUTER.
  185. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  186.     set(hObject,'BackgroundColor','white');
  187. end
  188.  
  189.  
  190. % --- Executes on button press in MC.
  191. function MC_Callback(hObject, eventdata, handles)
  192.  
  193. fun=str2func(['@(x) ' get(handles.funkcja,'String')]);
  194.  
  195. A=str2num(get(handles.a,'String'));
  196. B=str2num(get(handles.b,'String'));
  197. N=str2num(get(handles.n,'String'));
  198. set(handles.QUADval,'String',num2str(quad(fun,A,B),'%.4f'))
  199.  
  200.  
  201. MonteCarlo(fun,A,B,N,hObject);
  202.  
  203. % hObject    handle to MC (see GCBO)
  204. % eventdata  reserved - to be defined in a future version of MATLAB
  205. % handles    structure with handles and user data (see GUIDATA)
Advertisement
Add Comment
Please, Sign In to add comment