Practica 7 - JPRM

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

UNIVERSIDAD PRIVADA DEL VALLE

FACULTAD DE TECNOLOGIA
CARRERA INGENIERIA CIVIL

PRACTICA 9
INTERFAZ GRAFICA

Estudiante: Juan Lucio Bautista Arratia


Docente: Ing. Soliz Pablo
Asignatura: Métodos Numéricos
Grupo: C
Fecha: 15/12/2021
PRACTICA 9 – METODOS NUMERICOS
INTERFAZ GRAFICA

1. Determine el desarrollo en serie de Maclaurin para la función coseno y en base a esta:

Desarrollar una GUI que grafique la función coseno, pero en la que se pueda seleccionar el
número de los términos en la serie que aproxima la función coseno.

El desarrollo en serie de Maclaurin para la función coseno


2 4 2n
x x n x
cos ( x )=1− + −…+ (−1 )
2! 4! ( 2 n) !

INTERFAZ
function varargout = PRACT1(varargin)
% PRACT1 MATLAB code for PRACT1.fig
% PRACT1, by itself, creates a new PRACT1 or raises the existing
% singleton*.
%
% H = PRACT1 returns the handle to a new PRACT1 or the handle to
% the existing singleton*.
%
% PRACT1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PRACT1.M with the given input
arguments.
%
% PRACT1('Property','Value',...) creates a new PRACT1 or raises the
% existing singleton*. Starting from the left, property value pairs
are
% applied to the GUI before PRACT1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to PRACT1_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

% Edit the above text to modify the response to help PRACT1

% Last Modified by GUIDE v2.5 08-Dec-2020 10:59:05

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @PRACT1_OpeningFcn, ...
'gui_OutputFcn', @PRACT1_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 PRACT1 is made visible.


function PRACT1_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 PRACT1 (see VARARGIN)

% Choose default command line output for PRACT1


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes PRACT1 wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = PRACT1_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;

function n_Callback(hObject, eventdata, handles)


% hObject handle to n (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,'String') returns contents of n as text


% str2double(get(hObject,'String')) returns contents of n as a
double

% --- Executes during object creation, after setting all properties.


function n_CreateFcn(hObject, eventdata, handles)
% hObject handle to n (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 button press in graf.


function graf_Callback(hObject, eventdata, handles)
% hObject handle to graf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
syms x
nn=eval(get(handles.n,'string'));

for i=1:nn
fc=(-1)^i*x^(2*i)/factorial(2*i);
end

fplot(handles.axes1,fc,[-150;150]);

% --- Executes on button press in limpia.


function limpia_Callback(hObject, eventdata, handles)
% hObject handle to limpia (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
limpia=' ';
set(handles.n,'string',limpia)

% --- Executes on button press in sal.


function sal_Callback(hObject, eventdata, handles)
% hObject handle to sal (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(gcbf);
SOLUCION

2. Diseñe una interfaz grafica en la que se lea alguna de las funciones trigonométricas y
se grafique en un rango dado por el usuario. Se debe leer la función como:
sen ( 2∗pi∗x ) ,cos ( 2∗pi∗x ) , tan ( 2∗pi∗x ) , sec ( 2∗pi∗x ) , csc ( 2∗pi∗x ) , cot ( 2∗pi∗x ) .

INTERFAZ
function varargout = PRACT2(varargin)
% PRACT2 MATLAB code for PRACT2.fig
% PRACT2, by itself, creates a new PRACT2 or raises the existing
% singleton*.
%
% H = PRACT2 returns the handle to a new PRACT2 or the handle to
% the existing singleton*.
%
% PRACT2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PRACT2.M with the given input
arguments.
%
% PRACT2('Property','Value',...) creates a new PRACT2 or raises the
% existing singleton*. Starting from the left, property value pairs
are
% applied to the GUI before PRACT2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to PRACT2_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

% Edit the above text to modify the response to help PRACT2

% Last Modified by GUIDE v2.5 08-Dec-2020 10:31:12

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @PRACT2_OpeningFcn, ...
'gui_OutputFcn', @PRACT2_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 PRACT2 is made visible.


function PRACT2_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 PRACT2 (see VARARGIN)

% Choose default command line output for PRACT2


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes PRACT2 wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = PRACT2_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;

function fun_Callback(hObject, eventdata, handles)


% hObject handle to fun (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,'String') returns contents of fun as text


% str2double(get(hObject,'String')) returns contents of fun as a
double

% --- Executes during object creation, after setting all properties.


function fun_CreateFcn(hObject, eventdata, handles)
% hObject handle to fun (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

function rans_Callback(hObject, eventdata, handles)


% hObject handle to rans (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,'String') returns contents of rans as text


% str2double(get(hObject,'String')) returns contents of rans as a
double

% --- Executes during object creation, after setting all properties.


function rans_CreateFcn(hObject, eventdata, handles)
% hObject handle to rans (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 button press in graf.


function graf_Callback(hObject, eventdata, handles)
% hObject handle to graf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
syms x
f=eval(get(handles.fun,'string'));
rin=eval(get(handles.rani,'string'));
rsup=eval(get(handles.rans,'string'));
rango=char([rin;rsup]);
fplot(handles.axes1,f,rango);

% --- Executes on button press in sal.


function sal_Callback(hObject, eventdata, handles)
% hObject handle to sal (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(gcbf);

function rani_Callback(hObject, eventdata, handles)


% hObject handle to rani (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,'String') returns contents of rani as text


% str2double(get(hObject,'String')) returns contents of rani as a
double

% --- Executes during object creation, after setting all properties.


function rani_CreateFcn(hObject, eventdata, handles)
% hObject handle to rani (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 button press in limpia.


function limpia_Callback(hObject, eventdata, handles)
% hObject handle to limpia (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
limpia=' ';
set(handles.fun,'string',limpia)
set(handles.rani,'string',limpia)
set(handles.rans,'string',limpia)

SOLUCION

3. Diseñe una interfaz en la cual se ingrese una función y una constante. Mediante la
misma calcule la derivada simplifique la expresión, calcule la integral indefinida, evalué
en la constante ingresada y grafique la función.
INTERFAZ
function varargout = PRACT3(varargin)
% PRACT3 MATLAB code for PRACT3.fig
% PRACT3, by itself, creates a new PRACT3 or raises the existing
% singleton*.
%
% H = PRACT3 returns the handle to a new PRACT3 or the handle to
% the existing singleton*.
%
% PRACT3('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PRACT3.M with the given input
arguments.
%
% PRACT3('Property','Value',...) creates a new PRACT3 or raises the
% existing singleton*. Starting from the left, property value pairs
are
% applied to the GUI before PRACT3_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to PRACT3_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

% Edit the above text to modify the response to help PRACT3

% Last Modified by GUIDE v2.5 07-Dec-2020 18:31:22

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @PRACT3_OpeningFcn, ...
'gui_OutputFcn', @PRACT3_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 PRACT3 is made visible.


function PRACT3_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 PRACT3 (see VARARGIN)

% Choose default command line output for PRACT3


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes PRACT3 wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = PRACT3_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;

function fx_Callback(hObject, eventdata, handles)


% hObject handle to fx (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,'String') returns contents of fx as text


% str2double(get(hObject,'String')) returns contents of fx as a
double

% --- Executes during object creation, after setting all properties.


function fx_CreateFcn(hObject, eventdata, handles)
% hObject handle to fx (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

function a_Callback(hObject, eventdata, handles)


% hObject handle to a (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,'String') returns contents of a as text


% str2double(get(hObject,'String')) returns contents of a as a
double

% --- Executes during object creation, after setting all properties.


function a_CreateFcn(hObject, eventdata, handles)
% hObject handle to a (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

function der_Callback(hObject, eventdata, handles)


% hObject handle to der (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,'String') returns contents of der as text


% str2double(get(hObject,'String')) returns contents of der as a
double

% --- Executes during object creation, after setting all properties.


function der_CreateFcn(hObject, eventdata, handles)
% hObject handle to der (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

function sim_Callback(hObject, eventdata, handles)


% hObject handle to sim (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,'String') returns contents of sim as text


% str2double(get(hObject,'String')) returns contents of sim as a
double

% --- Executes during object creation, after setting all properties.


function sim_CreateFcn(hObject, eventdata, handles)
% hObject handle to sim (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
function int_Callback(hObject, eventdata, handles)
% hObject handle to int (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,'String') returns contents of int as text


% str2double(get(hObject,'String')) returns contents of int as a
double

% --- Executes during object creation, after setting all properties.


function int_CreateFcn(hObject, eventdata, handles)
% hObject handle to int (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 button press in derivar.


function derivar_Callback(hObject, eventdata, handles)
% hObject handle to derivar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
syms x
f=eval(get(handles.fx,'string'));
deriv=char(diff(f,x));
set(handles.der,'string',deriv);

% --- Executes on button press in simplif.


function simplif_Callback(hObject, eventdata, handles)
% hObject handle to simplif (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
syms x
f=eval(get(handles.fx,'string'));

simp=char(simplify(f));
set(handles.sim,'string',simp);

% --- Executes on button press in intdef.


function intdef_Callback(hObject, eventdata, handles)
% hObject handle to intdef (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
syms x
f=eval(get(handles.fx,'string'));

integral=char(int(f));
set(handles.int,'string',integral);

% --- Executes on button press in graficar.


function graficar_Callback(hObject, eventdata, handles)
% hObject handle to graficar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
f=get(handles.fx,'string');
syms x
ezplot(handles.axes1,f,[-150;150]);

% --- Executes on button press in eval.


function eval_Callback(hObject, eventdata, handles)
% hObject handle to eval (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
syms x
f=eval(get(handles.fx,'string'));
a=eval(get(handles.a,'string'));
e=char(subs(f,a));
set(handles.ev,'string',e);

function ev_Callback(hObject, eventdata, handles)


% hObject handle to ev (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,'String') returns contents of ev as text


% str2double(get(hObject,'String')) returns contents of ev as a
double

% --- Executes during object creation, after setting all properties.


function ev_CreateFcn(hObject, eventdata, handles)
% hObject handle to ev (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 button press in salir.


function salir_Callback(hObject, eventdata, handles)
% hObject handle to salir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(gcbf);

% --- Executes on button press in limpia.


function limpia_Callback(hObject, eventdata, handles)
% hObject handle to limpia (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
limpia=' ';
set(handles.fx,'string',limpia)
set(handles.a,'string',limpia)

SOLUCION

4. Diseñe una interfaz en la cual ingrese una temperatura en una de las escalas: Celsius,
kelvin, Fahrenheit; y pueda convertir a las otras dos escalas restantes. La GUI puede
ser similar a:
INTERFAZ
function varargout = PRACT4(varargin)
% PRACT4 MATLAB code for PRACT4.fig
% PRACT4, by itself, creates a new PRACT4 or raises the existing
% singleton*.
%
% H = PRACT4 returns the handle to a new PRACT4 or the handle to
% the existing singleton*.
%
% PRACT4('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PRACT4.M with the given input
arguments.
%
% PRACT4('Property','Value',...) creates a new PRACT4 or raises the
% existing singleton*. Starting from the left, property value pairs
are
% applied to the GUI before PRACT4_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to PRACT4_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

% Edit the above text to modify the response to help PRACT4

% Last Modified by GUIDE v2.5 07-Dec-2020 13:50:12

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @PRACT4_OpeningFcn, ...
'gui_OutputFcn', @PRACT4_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 PRACT4 is made visible.


function PRACT4_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 PRACT4 (see VARARGIN)

% Choose default command line output for PRACT4


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);
% UIWAIT makes PRACT4 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = PRACT4_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;

function cel_Callback(hObject, eventdata, handles)


% hObject handle to cel (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,'String') returns contents of cel as text


% str2double(get(hObject,'String')) returns contents of cel as a
double

% --- Executes during object creation, after setting all properties.


function cel_CreateFcn(hObject, eventdata, handles)
% hObject handle to cel (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

function kel_Callback(hObject, eventdata, handles)


% hObject handle to kel (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,'String') returns contents of kel as text


% str2double(get(hObject,'String')) returns contents of kel as a
double

% --- Executes during object creation, after setting all properties.


function kel_CreateFcn(hObject, eventdata, handles)
% hObject handle to kel (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

function fahr_Callback(hObject, eventdata, handles)


% hObject handle to fahr (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,'String') returns contents of fahr as text


% str2double(get(hObject,'String')) returns contents of fahr as a
double

% --- Executes during object creation, after setting all properties.


function fahr_CreateFcn(hObject, eventdata, handles)
% hObject handle to fahr (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 button press in pushbutton1.


function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
micel=get(handles.cel,'string');
mikel=str2double(micel)+273.15;
set(handles.kel,'string',num2str(mikel));
mifah=str2double(micel)*1.8+32;
set(handles.fahr,'string',num2str(mifah));

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mikel=get(handles.kel,'string');
mifah=(str2double(mikel)-273.15)*(9/5)+32;
set(handles.fahr,'string',num2str(mifah));
micel=str2double(mikel)-273.15;
set(handles.cel,'string',num2str(micel));

% --- Executes on button press in pushbutton3.


function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mifah=get(handles.fahr,'string');
micel=double((str2double(mifah)-32)*0.555);
mikel=double((str2double(mifah)-32)*(5/9)+273.15);
set(handles.cel,'string',num2str(micel));
set(handles.kel,'string',num2str(mikel));
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(gcbf);

% --- Executes on button press in pushbutton6.


function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton7.


function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
limpia=' ';
set(handles.cel,'string',limpia)
set(handles.kel,'string',limpia)
set(handles.fahr,'string',limpia)
SOLUCION

You might also like