0% found this document useful (0 votes)
16 views4 pages

Ejemplo

The document describes a MATLAB code for a GUI called Ejemplo. It contains functions for creating and opening the GUI, handling callbacks and outputs. It initializes the GUI, defines callbacks for buttons that perform mathematical operations like addition, subtraction etc. on input values and display the output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

Ejemplo

The document describes a MATLAB code for a GUI called Ejemplo. It contains functions for creating and opening the GUI, handling callbacks and outputs. It initializes the GUI, defines callbacks for buttons that perform mathematical operations like addition, subtraction etc. on input values and display the output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

function varargout = Ejemplo(varargin)

% EJEMPLO MATLAB code for Ejemplo.fig


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

% Last Modified by GUIDE v2.5 19-Sep-2023 09:46:49

% Begin initialization code - DO NOT EDIT


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


function Ejemplo_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 Ejemplo (see VARARGIN)

% Choose default command line output for Ejemplo


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

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


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = Ejemplo_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 n1_Callback(hObject, eventdata, handles)


% hObject handle to n1 (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 n1 as text


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

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


function n1_CreateFcn(hObject, eventdata, handles)
% hObject handle to n1 (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 n2_Callback(hObject, eventdata, handles)


% hObject handle to n2 (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 n2 as text


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

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


function n2_CreateFcn(hObject, eventdata, handles)
% hObject handle to n2 (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 boton1.


function boton1_Callback(hObject, eventdata, handles)
v1=str2num(get(handles.n1,'string'))
v2=str2num(get(handles.n2,'string'))
s=v1+v2;
su=num2str(s);
set(handles.Resultado,'string',su)

%set(handles.grafica,'string',
plot(v1,v2)

function edit3_Callback(hObject, eventdata, handles)


% hObject handle to edit3 (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 edit3 as text


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

% --- 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 on button press in boton2.


function boton2_Callback(hObject, eventdata, handles)
v1=str2num(get(handles.n1,'string'))
v2=str2num(get(handles.n2,'string'))
r=v1-v2;
re=num2str(r);
set(handles.Resultado,'string',re)

% --- Executes on button press in boton3.


function boton3_Callback(hObject, eventdata, handles)
v1=str2num(get(handles.n1,'string'))
v2=str2num(get(handles.n2,'string'))
m=v1*v2;
mult=num2str(m);
set(handles.Resultado,'string',mult)

% --- Executes on button press in boton4.


function boton4_Callback(hObject, eventdata, handles)
v1=str2num(get(handles.n1,'string'))
v2=str2num(get(handles.n2,'string'))
d=v1/v2;
div=num2str(d);
set(handles.Resultado,'string',div)

% --- Executes on button press in boton5.


function boton5_Callback(hObject, eventdata, handles)
v1=str2num(get(handles.n1,'string'))
v2=str2num(get(handles.n2,'string'))
p=(v1^v2);
po=num2str(p);
set(handles.Resultado,'string',po)

% --- Executes on button press in boton6.


function boton6_Callback(hObject, eventdata, handles)
v1=str2num(get(handles.n1,'string'))
v2=str2num(get(handles.n2,'string'))
ra=(v1^(1/v2));
raiz=num2str(ra);
set(handles.Resultado,'string',raiz)

You might also like