Anda di halaman 1dari 13

[matlab]

2012

TEMPERATURE CONVERSION CALCULATOR

Saya tampilkan konvertor suhu yang terdiri atas 8 jenis:

Codenya adalah
function varargout = tempCalc(varargin) % TEMPCALC M-file for tempCalc.fig % TEMPCALC, by itself, creates a new TEMPCALC or raises the existing % singleton*. % % H = TEMPCALC returns the handle to a new TEMPCALC or the handle to % the existing singleton*. % % TEMPCALC('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in TEMPCALC.M with the given input arguments. % % TEMPCALC('Property','Value',...) creates a new TEMPCALC or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before tempCalc_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to tempCalc_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES
[janshendry@gmail.com]

[matlab]

2012

% Edit the above text to modify the response to help tempCalc % Last Modified by GUIDE v2.5 06-Nov-2012 15:54:31 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @tempCalc_OpeningFcn, ... 'gui_OutputFcn', @tempCalc_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT

% --- Executes just before tempCalc is made visible. function tempCalc_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to tempCalc (see VARARGIN) % Choose default command line output for tempCalc handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes tempCalc wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line. function varargout = tempCalc_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output;

[janshendry@gmail.com]

[matlab]

2012

% --- Executes on slider movement. function slider1_Callback(hObject, eventdata, handles) % hObject handle to slider1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider C = get(hObject, 'value'); set(handles.edit1, 'string', num2str(C)); [F, K, R, Ra, D, N, Ro] = CtoAll(C); set(handles.slider2, 'value', F); set(handles.edit2, 'string', num2str(F)); set(handles.slider3, 'value', K); set(handles.edit3, 'string', num2str(K)); set(handles.slider4, 'value', R); set(handles.edit4, 'string', num2str(R)); set(handles.slider5, 'value', Ra); set(handles.edit5, 'string', num2str(Ra)); set(handles.slider6, 'value', D); set(handles.edit6, 'string', num2str(D)); set(handles.slider7, 'value', N); set(handles.edit7, 'string', num2str(N)); set(handles.slider8, 'value', Ro); set(handles.edit8, 'string', num2str(Ro)); function [F, K, R, Ra, D, N, Ro] = CtoAll(C) F = C * (9/5) + 32; K = C + 273.15; R = C * (4/5); Ra = (C + 273.15) * (9/5); % K * (9/5) D = (100 - C) * (3/2); N = C * (33/100); Ro = (C * (21/40)) + 7.5;

% --- Executes during object creation, after setting all properties. function slider1_CreateFcn(hObject, eventdata, handles) % hObject handle to slider1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end

% --- Executes on slider movement.


[janshendry@gmail.com]

[matlab]

2012

function slider2_Callback(hObject, eventdata, handles) % hObject handle to slider2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider F = get(hObject, 'value'); set(handles.edit2, 'string', num2str(F)); [C, K, R, Ra, D, N, Ro] = FtoAll(F); set(handles.slider1, 'value', C); set(handles.edit1, 'string', num2str(C)); set(handles.slider3, 'value', K); set(handles.edit3, 'string', num2str(K)); set(handles.slider4, 'value', R); set(handles.edit4, 'string', num2str(R)); set(handles.slider5, 'value', Ra); set(handles.edit5, 'string', num2str(Ra)); set(handles.slider6, 'value', D); set(handles.edit6, 'string', num2str(D)); set(handles.slider7, 'value', N); set(handles.edit7, 'string', num2str(N)); set(handles.slider8, 'value', Ro); set(handles.edit8, 'string', num2str(Ro)); function [C, K, R, Ra, D, N, Ro] = FtoAll(F) C = (F - 32) * 5/9; K = (F + 459.67) * 5/9; Ra = F + 459.67; D = (212 - F) * 5/6; N = (F - 32) * 11/60; R = (F - 32) * 4/9; Ro = (F - 32) * 7/24 + 7.5; % --- Executes during object creation, after setting all properties. function slider2_CreateFcn(hObject, eventdata, handles) % hObject handle to slider2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end

% --- Executes on slider movement. function slider3_Callback(hObject, eventdata, handles) % hObject handle to slider3 (see GCBO)
[janshendry@gmail.com]

[matlab]

2012

% eventdata % handles

reserved - to be defined in a future version of MATLAB structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider R = get(hObject, 'value'); set(handles.edit3, 'string', num2str(R)); [C, F, K, Ra, D, N, Ro] = RtoAll(R); set(handles.slider1, 'value', C); set(handles.edit1, 'string', num2str(C)); set(handles.slider2, 'value', F); set(handles.edit2, 'string', num2str(F)); set(handles.slider4, 'value', K); set(handles.edit4, 'string', num2str(K)); set(handles.slider5, 'value', Ra); set(handles.edit5, 'string', num2str(Ra)); set(handles.slider6, 'value', D); set(handles.edit6, 'string', num2str(D)); set(handles.slider7, 'value', N); set(handles.edit7, 'string', num2str(N)); set(handles.slider8, 'value', Ro); set(handles.edit8, 'string', num2str(Ro)); function [C, K, F, Ra, D, N, Ro] = RtoAll(R) C = R * 5/4; F = R * 9/4 + 32; K = R * 5/4 + 273.15; Ra = R * 9/4 + 491.67; D = (80 - R) * 15/8; N = R * 33/80; Ro = R * 21/32 + 7.5; % --- Executes during object creation, after setting all properties. function slider3_CreateFcn(hObject, eventdata, handles) % hObject handle to slider3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end

% --- Executes on slider movement. function slider4_Callback(hObject, eventdata, handles) % hObject handle to slider4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

[janshendry@gmail.com]

[matlab]

2012

% Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider K = get(hObject, 'value'); set(handles.edit4, 'string', num2str(K)); [C, F, R, Ra, D, N, Ro] = KtoAll(K); set(handles.slider1, 'value', C); set(handles.edit1, 'string', num2str(C)); set(handles.slider2, 'value', F); set(handles.edit2, 'string', num2str(F)); set(handles.slider3, 'value', R); set(handles.edit3, 'string', num2str(R)); set(handles.slider5, 'value', Ra); set(handles.edit5, 'string', num2str(Ra)); set(handles.slider6, 'value', D); set(handles.edit6, 'string', num2str(D)); set(handles.slider7, 'value', N); set(handles.edit7, 'string', num2str(N)); set(handles.slider8, 'value', Ro); set(handles.edit8, 'string', num2str(Ro)); function [C, F, R, Ra, D, N, Ro] = KtoAll(K) C = K - 273.15; F = K * 9/5 - 459.67; Ra = K * 9/5; D = (373.15 - K) * 3/2; N = (K - 273.15) * 33/100; R = (K - 273.15) * 4/5; Ro = (K - 273.15) * 21/40 + 7.5; % --- Executes during object creation, after setting all properties. function slider4_CreateFcn(hObject, eventdata, handles) % hObject handle to slider4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end % --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
[janshendry@gmail.com]

[matlab]

2012

end % --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on slider movement. function slider5_Callback(hObject, eventdata, handles) % hObject handle to slider5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider Ra = get(hObject, 'value'); set(handles.edit5, 'string', num2str(Ra));

[janshendry@gmail.com]

[matlab]

2012

[C, F, R, K, D, N, Ro] = RatoAll(Ra); set(handles.slider1, 'value', C); set(handles.edit1, 'string', num2str(C)); set(handles.slider2, 'value', F); set(handles.edit2, 'string', num2str(F)); set(handles.slider3, 'value', R); set(handles.edit3, 'string', num2str(R)); set(handles.slider4, 'value', K); set(handles.edit4, 'string', num2str(K)); set(handles.slider6, 'value', D); set(handles.edit6, 'string', num2str(D)); set(handles.slider7, 'value', N); set(handles.edit7, 'string', num2str(N)); set(handles.slider8, 'value', Ro); set(handles.edit8, 'string', num2str(Ro)); function [C, F, R, K, D, N, Ro] = RatoAll(Ra) C = (Ra - 491.67) * 5/9; F = Ra - 459.67; K = Ra * 5/9; D = (671.67 - Ra) * 5/6; N = (Ra - 491.67) * 11/60; R = (Ra - 491.67) * 4/9; Ro = (Ra - 491.67) * 7/24 + 7.5;

% --- Executes during object creation, after setting all properties. function slider5_CreateFcn(hObject, eventdata, handles) % hObject handle to slider5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end

% --- Executes on slider movement. function slider6_Callback(hObject, eventdata, handles) % hObject handle to slider6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider D = get(hObject, 'value'); set(handles.edit6, 'string', num2str(D)); [C, F, R, K, Ra, N, Ro] = DtoAll(D); set(handles.slider1, 'value', C);
[janshendry@gmail.com]

[matlab]

2012

set(handles.edit1, 'string', num2str(C)); set(handles.slider2, 'value', F); set(handles.edit2, 'string', num2str(F)); set(handles.slider3, 'value', R); set(handles.edit3, 'string', num2str(R)); set(handles.slider4, 'value', K); set(handles.edit4, 'string', num2str(K)); set(handles.slider5, 'value', Ra); set(handles.edit5, 'string', num2str(Ra)); set(handles.slider7, 'value', N); set(handles.edit7, 'string', num2str(N)); set(handles.slider8, 'value', Ro); set(handles.edit8, 'string', num2str(Ro)); function [C, F, R, K, Ra, N, Ro] = DtoAll(D) C = 100 - D * 2/3; K = 373.15 - D * 2/3; F = 212 - D * 6/5; Ra = 671.67 - D * 6/5; N = 33 - D * 11/50; R = 80 - D * 8/15; Ro = 60 - D * 7/20;

% --- Executes during object creation, after setting all properties. function slider6_CreateFcn(hObject, eventdata, handles) % hObject handle to slider6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end

% --- Executes on slider movement. function slider7_Callback(hObject, eventdata, handles) % hObject handle to slider7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider N = get(hObject, 'value'); set(handles.edit7, 'string', num2str(N)); [C, F, R, K, Ra, D, Ro] = NtoAll(N); set(handles.slider1, 'value', C); set(handles.edit1, 'string', num2str(C)); set(handles.slider2, 'value', F);
[janshendry@gmail.com]

[matlab]

2012

set(handles.edit2, 'string', num2str(F)); set(handles.slider3, 'value', R); set(handles.edit3, 'string', num2str(R)); set(handles.slider4, 'value', K); set(handles.edit4, 'string', num2str(K)); set(handles.slider5, 'value', Ra); set(handles.edit5, 'string', num2str(Ra)); set(handles.slider6, 'value', D); set(handles.edit6, 'string', num2str(D)); set(handles.slider8, 'value', Ro); set(handles.edit8, 'string', num2str(Ro)); function [C, F, R, K, Ra, D, Ro] = NtoAll(N) C = N * 100/33; F = N * 60/11 + 32; K = N * 100/33 + 273.15; Ra = N * 60/11 + 491.67; D = (33 - N) * 50/11; R = N * 80/33; Ro = N * 35/22 + 7.5; % --- Executes during object creation, after setting all properties. function slider7_CreateFcn(hObject, eventdata, handles) % hObject handle to slider7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end

% --- Executes on slider movement. function slider8_Callback(hObject, eventdata, handles) % hObject handle to slider8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider Ro = get(hObject, 'value'); set(handles.edit8, 'string', num2str(Ro)); set(handles.edit8, 'tooltipstring', num2str(Ro)); [C, F, R, K, Ra, D, N] = RotoAll(Ro); set(handles.slider1, 'value', C); set(handles.edit1, 'string', num2str(C)); set(handles.slider2, 'value', F); set(handles.edit2, 'string', num2str(F)); set(handles.slider3, 'value', R); set(handles.edit3, 'string', num2str(R));
[janshendry@gmail.com]

[matlab]

2012

set(handles.slider4, 'value', K); set(handles.edit4, 'string', num2str(K)); set(handles.slider5, 'value', Ra); set(handles.edit5, 'string', num2str(Ra)); set(handles.slider6, 'value', D); set(handles.edit6, 'string', num2str(D)); set(handles.slider7, 'value', N); set(handles.edit7, 'string', num2str(N)); function [C, F, R, K, Ra, D, N] = RotoAll(Ro) C = (Ro - 7.5) * 40/21; F = (Ro - 7.5) * 24/7 + 32; K = (Ro - 7.5) * 40/21 + 273.15; Ra = (Ro - 7.5) * 24/7 + 491.67; D = (60 - Ro) * 20/7; N = (Ro - 7.5) * 22/35; R = (Ro - 7.5) * 32/21; % --- Executes during object creation, after setting all properties. function slider8_CreateFcn(hObject, eventdata, handles) % hObject handle to slider8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end % --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes during object creation, after setting all properties. function edit6_CreateFcn(hObject, eventdata, handles) % hObject handle to edit6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
[janshendry@gmail.com]

[matlab]

2012

end % --- Executes during object creation, after setting all properties. function edit7_CreateFcn(hObject, eventdata, handles) % hObject handle to edit7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes during object creation, after setting all properties. function edit8_CreateFcn(hObject, eventdata, handles) % hObject handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

Program ini hanyalah sederhana dan cupu (bahasa gaulnya). Tapi anda bisa belajar tentang penggunaan dari slider tool pada Matlab, tentu bagi yang belum bisa.

@ thanks
[janshendry@gmail.com]

[matlab]

2012

[janshendry@gmail.com]

Anda mungkin juga menyukai