Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.34 KB | None | 0 0
  1. function varargout = alkomat2(varargin)
  2. % ALKOMAT2 MATLAB code for alkomat2.fig
  3. % ALKOMAT2, by itself, creates a new ALKOMAT2 or raises the existing
  4. % singleton*.
  5. %
  6. % H = ALKOMAT2 returns the handle to a new ALKOMAT2 or the handle to
  7. % the existing singleton*.
  8. %
  9. % ALKOMAT2('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in ALKOMAT2.M with the given input arguments.
  11. %
  12. % ALKOMAT2('Property','Value',...) creates a new ALKOMAT2 or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before alkomat2_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to alkomat2_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 alkomat2
  24.  
  25. % Last Modified by GUIDE v2.5 17-Jan-2017 12:57:43
  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', @alkomat2_OpeningFcn, ...
  32. 'gui_OutputFcn', @alkomat2_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. end
  46. % --- Executes just before alkomat2 is made visible.
  47. function alkomat2_OpeningFcn(hObject, eventdata, handles, varargin)
  48. % This function has no output args, see OutputFcn.
  49. % hObject handle to figure
  50. % eventdata reserved - to be defined in a future version of MATLAB
  51. % handles structure with handles and user data (see GUIDATA)
  52. % varargin command line arguments to alkomat2 (see VARARGIN)
  53.  
  54. % Choose default command line output for alkomat2
  55. handles.output = hObject;
  56.  
  57. % Update handles structure
  58. guidata(hObject, handles);
  59. end
  60. % UIWAIT makes alkomat2 wait for user response (see UIRESUME)
  61. % uiwait(handles.figure1);
  62.  
  63.  
  64. % --- Outputs from this function are returned to the command line.
  65. function varargout = alkomat2_OutputFcn(hObject, eventdata, handles)
  66. % varargout cell array for returning output args (see VARARGOUT);
  67. % hObject handle to figure
  68. % eventdata reserved - to be defined in a future version of MATLAB
  69. % handles structure with handles and user data (see GUIDATA)
  70.  
  71. % Get default command line output from handles structure
  72. varargout{1} = handles.output;
  73. end
  74.  
  75. % --- Executes on selection change in wybor_plci.
  76. function wybor_plci_Callback(hObject, eventdata, handles)
  77. % hObject handle to wybor_plci (see GCBO)
  78. % eventdata reserved - to be defined in a future version of MATLAB
  79. % handles structure with handles and user data (see GUIDATA)
  80.  
  81. sex = get(handles.wybor_plci, 'String')
  82. handles.sex = sex
  83. if sex == 'K'
  84. wspolczynnik = 0,6 ;
  85. else
  86. wspolczynnik = 0,7;
  87. end
  88.  
  89. handles.wspolczynnik = wspolczynnik
  90. end
  91. % Hints: contents = cellstr(get(hObject,'String')) returns wybor_plci contents as cell array
  92. % contents{get(hObject,'Value')} returns selected item from wybor_plci
  93.  
  94.  
  95. % --- Executes during object creation, after setting all properties.
  96. function wybor_plci_CreateFcn(hObject, eventdata, handles)
  97. % hObject handle to wybor_plci (see GCBO)
  98. % eventdata reserved - to be defined in a future version of MATLAB
  99. % handles empty - handles not created until after all CreateFcns called
  100.  
  101. % Hint: popupmenu controls usually have a white background on Windows.
  102. % See ISPC and COMPUTER.
  103. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  104. set(hObject,'BackgroundColor','white');
  105. end
  106. end
  107.  
  108.  
  109. function waga_Callback(hObject, eventdata, handles)
  110. % hObject handle to waga (see GCBO)
  111. % eventdata reserved - to be defined in a future version of MATLAB
  112. % handles structure with handles and user data (see GUIDATA)
  113.  
  114. a = get(handles.waga, 'String')
  115. b = str2double(a)
  116. if sex ==K
  117. x = 0,6
  118. else
  119. x = 0,7
  120. end
  121. waga = b*x
  122. handles.waga = waga
  123. end
  124.  
  125. % Hints: get(hObject,'String') returns contents of waga as text
  126. % str2double(get(hObject,'String')) returns contents of waga as a double
  127.  
  128.  
  129. % --- Executes during object creation, after setting all properties.
  130. function waga_CreateFcn(hObject, eventdata, handles)
  131. % hObject handle to waga (see GCBO)
  132. % eventdata reserved - to be defined in a future version of MATLAB
  133. % handles empty - handles not created until after all CreateFcns called
  134.  
  135. % Hint: edit controls usually have a white background on Windows.
  136. % See ISPC and COMPUTER.
  137. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  138. set(hObject,'BackgroundColor','white');
  139. end
  140. end
  141.  
  142.  
  143. function wzrost_Callback(hObject, eventdata, handles)
  144. % hObject handle to masa (see GCBO)
  145. % eventdata reserved - to be defined in a future version of MATLAB
  146. % handles structure with handles and user data (see GUIDATA)
  147.  
  148. wzrost_zmienna = get(handles.wzrost, 'String')
  149. wzrost = str2double(wzrost_zmienna)
  150. handles.wzrost = wzrost
  151. end
  152. function [ilosc_plynow] = obliczilosc_plynow(waga,wzrost,wspolczynnik)
  153. BMI= waga/(wzrost/100)^2 ;
  154. if BMI >25
  155. z=BMI-25;
  156. y= z*3,0625
  157. elseif BMI<18,5
  158. z=18,5-BMI
  159. y = z*3,0625
  160. else
  161. y=BMI
  162. end
  163.  
  164. waga_beztluszczu = waga-y;
  165. ilosc_plynow = waga_beztluszczu*wspolczynnik
  166.  
  167.  
  168. % Hints: get(hObject,'String') returns contents of masa as text
  169. % str2double(get(hObject,'String')) returns contents of masa as a double
  170.  
  171.  
  172. % --- Executes during object creation, after setting all properties.
  173. function wzrost_CreateFcn(hObject, eventdata, handles)
  174. % hObject handle to masa (see GCBO)
  175. % eventdata reserved - to be defined in a future version of MATLAB
  176. % handles empty - handles not created until after all CreateFcns called
  177.  
  178. % Hint: edit controls usually have a white background on Windows.
  179. % See ISPC and COMPUTER.
  180. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  181. set(hObject,'BackgroundColor','white');
  182. end
  183. end
  184.  
  185.  
  186. function godzina_rozpoczecia_Callback(hObject, eventdata, handles)
  187. % hObject handle to godzina_rozpoczecia (see GCBO)
  188. % eventdata reserved - to be defined in a future version of MATLAB
  189. % handles structure with handles and user data (see GUIDATA)
  190.  
  191. % Hints: get(hObject,'String') returns contents of godzina_rozpoczecia as text
  192. % str2double(get(hObject,'String')) returns contents of godzina_rozpoczecia as a double
  193. end
  194.  
  195. % --- Executes during object creation, after setting all properties.
  196. function godzina_rozpoczecia_CreateFcn(hObject, eventdata, handles)
  197. % hObject handle to godzina_rozpoczecia (see GCBO)
  198. % eventdata reserved - to be defined in a future version of MATLAB
  199. % handles empty - handles not created until after all CreateFcns called
  200.  
  201. % Hint: edit controls usually have a white background on Windows.
  202. % See ISPC and COMPUTER.
  203. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  204. set(hObject,'BackgroundColor','white');
  205. end
  206. end
  207.  
  208.  
  209. function edit6_Callback(hObject, eventdata, handles)
  210. % hObject handle to edit6 (see GCBO)
  211. % eventdata reserved - to be defined in a future version of MATLAB
  212. % handles structure with handles and user data (see GUIDATA)
  213. end
  214. % Hints: get(hObject,'String') returns contents of edit6 as text
  215.  
  216. %str2double(get(hObject,'String')) returns contents of edit6 as a double
  217.  
  218.  
  219. % --- Executes during object creation, after setting all properties.
  220. function edit6_CreateFcn(hObject, eventdata, handles)
  221. % hObject handle to edit6 (see GCBO)
  222. % eventdata reserved - to be defined in a future version of MATLAB
  223. % handles empty - handles not created until after all CreateFcns called
  224.  
  225. % Hint: edit controls usually have a white background on Windows.
  226. % See ISPC and COMPUTER.
  227. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  228. set(hObject,'BackgroundColor','white');
  229. end
  230. end
  231.  
  232.  
  233. function czas_spozycia_Callback(hObject, eventdata, handles)
  234. % hObject handle to czas_spozycia (see GCBO)
  235. % eventdata reserved - to be defined in a future version of MATLAB
  236. % handles structure with handles and user data (see GUIDATA)
  237.  
  238. % Hints: get(hObject,'String') returns contents of czas_spozycia as text
  239. % str2double(get(hObject,'String')) returns contents of czas_spozycia as a double
  240.  
  241. end
  242. % --- Executes during object creation, after setting all properties.
  243. function czas_spozycia_CreateFcn(hObject, eventdata, handles)
  244. % hObject handle to czas_spozycia (see GCBO)
  245. % eventdata reserved - to be defined in a future version of MATLAB
  246. % handles empty - handles not created until after all CreateFcns called
  247.  
  248. % Hint: edit controls usually have a white background on Windows.
  249. % See ISPC and COMPUTER.
  250. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  251. set(hObject,'BackgroundColor','white');
  252. end
  253. end
  254.  
  255.  
  256. function objetosc_piwa_Callback(hObject, eventdata, handles)
  257. % hObject handle to objetosc_piwa (see GCBO)
  258. % eventdata reserved - to be defined in a future version of MATLAB
  259. % handles structure with handles and user data (see GUIDATA)
  260.  
  261. objetosc_piwa =get(handles.objetosc_piwa,'String')
  262. objetosc_piwa1 = str2double(objetosc_piwa)
  263. handles.objetosc_piwa1 = objetosc_piwa1
  264. end
  265. function [masa_alkoholu_piwo] = obliczmase_alkoholu_piwo(objetosc_piwa1)
  266. q = 1,79
  267. objetosc_alkoholu = objetosc_piwa1*procent_piwa1
  268. masa_alkoholu_piwo = objetosc_alkoholu*q
  269. end
  270. % Hints: get(hObject,'String') returns contents of objetosc_piwa as text
  271. % str2double(get(hObject,'String')) returns contents of objetosc_piwa as a double
  272.  
  273.  
  274. % --- Executes during object creation, after setting all properties.
  275. function objetosc_piwa_CreateFcn(hObject, eventdata, handles)
  276. % hObject handle to objetosc_piwa (see GCBO)
  277. % eventdata reserved - to be defined in a future version of MATLAB
  278. % handles empty - handles not created until after all CreateFcns called
  279.  
  280. % Hint: edit controls usually have a white background on Windows.
  281. % See ISPC and COMPUTER.
  282. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  283. set(hObject,'BackgroundColor','white');
  284. end
  285. end
  286.  
  287.  
  288. function objetosc_wina_Callback(hObject, eventdata, handles)
  289. % hObject handle to objetosc_wina (see GCBO)
  290. % eventdata reserved - to be defined in a future version of MATLAB
  291. % handles structure with handles and user data (see GUIDATA)
  292.  
  293. objetosc_wina =get(handles.objetosc_wina,'String')
  294. objetosc_wina1 = str2double(objetosc_wina)
  295. handles.objetosc_wina1 = objetosc_wina1
  296. end
  297. function [masa_alkoholu_wino] = obliczmase_alkoholu_wino(objetosc_wina1)
  298. q = 1,79
  299. objetosc_alkoholu = objetosc_wina1*procent_wina1
  300. masa_alkoholu_wino = objetosc_alkoholu*q
  301. end
  302.  
  303. % Hints: get(hObject,'String') returns contents of objetosc_wina as text
  304. % str2double(get(hObject,'String')) returns contents of objetosc_wina as a double
  305.  
  306.  
  307. % --- Executes during object creation, after setting all properties.
  308. function objetosc_wina_CreateFcn(hObject, eventdata, handles)
  309. % hObject handle to objetosc_wina (see GCBO)
  310. % eventdata reserved - to be defined in a future version of MATLAB
  311. % handles empty - handles not created until after all CreateFcns called
  312.  
  313. % Hint: edit controls usually have a white background on Windows.
  314. % See ISPC and COMPUTER.
  315. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  316. set(hObject,'BackgroundColor','white');
  317. end
  318. end
  319.  
  320.  
  321. function objetosc_wodki_Callback(hObject, eventdata, handles)
  322. % hObject handle to objetosc_wodki (see GCBO)
  323. % eventdata reserved - to be defined in a future version of MATLAB
  324. % handles structure with handles and user data (see GUIDATA)
  325.  
  326. objetosc_wodki =get(handles.objetosc_wodki,'String')
  327. objetosc_wodki1 = str2double(objetosc_wodki)
  328. handles.objetosc_wodki1 = objetosc_wodki1
  329. end
  330. function [masa_alkoholu_wodki] = obliczmase_alkoholu_wodki(objetosc_wodki1)
  331. q = 1,79
  332. objetosc_alkoholu = objetosc_wodki1*procent_piwa1
  333. masa_alkoholu_wodki = objetosc_alkoholu_wodki*q
  334. end
  335. % Hints: get(hObject,'String') returns contents of objetosc_wodki as text
  336. % str2double(get(hObject,'String')) returns contents of objetosc_wodki as a double
  337.  
  338.  
  339. % --- Executes during object creation, after setting all properties.
  340. function objetosc_wodki_CreateFcn(hObject, eventdata, handles)
  341. % hObject handle to objetosc_wodki (see GCBO)
  342. % eventdata reserved - to be defined in a future version of MATLAB
  343. % handles empty - handles not created until after all CreateFcns called
  344.  
  345. % Hint: edit controls usually have a white background on Windows.
  346. % See ISPC and COMPUTER.
  347. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  348. set(hObject,'BackgroundColor','white');
  349. end
  350. end
  351.  
  352.  
  353. function procent_piwa_Callback(hObject, eventdata, handles)
  354. % hObject handle to procent_piwa (see GCBO)
  355. % eventdata reserved - to be defined in a future version of MATLAB
  356. % handles structure with handles and user data (see GUIDATA)
  357.  
  358. procent_piwa = get(handles.procent_piwa,'String')
  359. procent_piwa1 = str2double(procent_piwa)
  360. handles.procent_piwa1 = procent_piwa1
  361. end
  362.  
  363. % Hints: get(hObject,'String') returns contents of procent_piwa as text
  364. % str2double(get(hObject,'String')) returns contents of procent_piwa as a double
  365.  
  366.  
  367. % --- Executes during object creation, after setting all properties.
  368. function procent_piwa_CreateFcn(hObject, eventdata, handles)
  369. % hObject handle to procent_piwa (see GCBO)
  370. % eventdata reserved - to be defined in a future version of MATLAB
  371. % handles empty - handles not created until after all CreateFcns called
  372.  
  373. % Hint: edit controls usually have a white background on Windows.
  374. % See ISPC and COMPUTER.
  375. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  376. set(hObject,'BackgroundColor','white');
  377. end
  378. end
  379.  
  380.  
  381. function procent_wina_Callback(hObject, eventdata, handles)
  382. % hObject handle to procent_wina (see GCBO)
  383. % eventdata reserved - to be defined in a future version of MATLAB
  384. % handles structure with handles and user data (see GUIDATA)
  385.  
  386. procent_wina = get(handles.procent_wina,'String')
  387. procent_wina1 = str2double(procent_wina)
  388. handles.procent_wina1 = procent_wina1
  389. end
  390. % Hints: get(hObject,'String') returns contents of procent_wina as text
  391. % str2double(get(hObject,'String')) returns contents of procent_wina as a double
  392.  
  393.  
  394. % --- Executes during object creation, after setting all properties.
  395. function procent_wina_CreateFcn(hObject, eventdata, handles)
  396. % hObject handle to procent_wina (see GCBO)
  397. % eventdata reserved - to be defined in a future version of MATLAB
  398. % handles empty - handles not created until after all CreateFcns called
  399.  
  400. % Hint: edit controls usually have a white background on Windows.
  401. % See ISPC and COMPUTER.
  402. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  403. set(hObject,'BackgroundColor','white');
  404. end
  405. end
  406.  
  407.  
  408. function procent_wodki_Callback(hObject, eventdata, handles)
  409. % hObject handle to procent_wodki (see GCBO)
  410. % eventdata reserved - to be defined in a future version of MATLAB
  411. % handles structure with handles and user data (see GUIDATA)
  412.  
  413. procent_wodki = get(handles.procent_wodki,'String')
  414. procent_wodki1 = str2double(procent_wodki)
  415. handles.procent_wodki1 = procent_wodki1
  416. end
  417. % Hints: get(hObject,'String') returns contents of procent_wodki as text
  418. % str2double(get(hObject,'String')) returns contents of procent_wodki as a double
  419.  
  420.  
  421. % --- Executes during object creation, after setting all properties.
  422. function procent_wodki_CreateFcn(hObject, eventdata, handles)
  423. % hObject handle to procent_wodki (see GCBO)
  424. % eventdata reserved - to be defined in a future version of MATLAB
  425. % handles empty - handles not created until after all CreateFcns called
  426.  
  427. % Hint: edit controls usually have a white background on Windows.
  428. % See ISPC and COMPUTER.
  429. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  430. set(hObject,'BackgroundColor','white');
  431. end
  432. end
  433.  
  434. masa_alkoholu_cala = masa_alkoholu_piwo + masa_alkoholu_wino + masa_alkoholu_wodki;
  435.  
  436. szybkosc = 10*masa_alkoholu_cala/4,2+masa_alkoholu_cala;
  437.  
  438. ilosc_promili = masa_alkoholu_cala/wspolczynnik*ilosc_plynow ;
  439.  
  440. czas_trzezwienia = masa_alkoholu_cala / szybkosc ;
  441.  
  442. % --- Executes on button press in oblicz_promile.
  443. function oblicz_promile_Callback(hObject, eventdata, handles)
  444. % hObject handle to oblicz_promile (see GCBO)
  445. % eventdata reserved - to be defined in a future version of MATLAB
  446. % handles structure with handles and user data (see GUIDATA)
  447. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement