9
Ingeniería Electromecánica Salomón Durán I N S T I T U T O T E C N O L O G I C O S U P E R I O R Ð S A N M A R T I N T E X M E L U C A N ORGANISMO PUBLICO DESCENTRALIZADO DEL GOBIERNO DEL ESTADO I N G E N I E R I A E L E C T R O M E C A N I C A ASIGNATURA: Ingeniería de control PROFESOR: Erasmo Saloma Ruiz PRESENTA: Salomón Durán Hernández

prac calculadora

Embed Size (px)

Citation preview

Page 1: prac calculadora

Ingeniería Electromecánica Salomón Durán

I N S T I T U T O T E C N O L O G I C O S U P E R I O R

Ð S A N M A R T I N T E X M E L U C A N

ORGANISMO PUBLICO DESCENTRALIZADO DEL GOBIERNO DEL

ESTADO

I N G E N I E R I A E L E C T R O M E C A N I C A

ASIGNATURA:

Ingeniería de control

PROFESOR:

Erasmo Saloma Ruiz

PRESENTA:

Salomón Durán Hernández

TRABAJO:

Practica calculadora

GRUPO: Séptimo “A” TURNO: Matutino

Page 2: prac calculadora

Ingeniería Electromecánica Salomón Durán

San Martín Texmelucan 16 de noviembre de 2010INTRODUCCION

Para esta practica se utilizo el GUIDE el cual es un entorno de programación visual disponible en MATLAB para realizar y ejecutar programas que necesiten ingreso continuo de datos.

Conociendo la herramienta que se va a realizar, continuamos con la realización de la practica que en nuestro caso será una calculadora sencilla con las operaciones básicas:SumaMultiplicaciónDivisiónResta

Desarrollo

Primero que nada para iniciar nuestra practica, hay que dar clik en el icono guide el cual nos abrirá el siguiente recuadro.

Al estar en el recuadro seleccionaremos la opción de blank gui. Estando abierto nos disponemos a realizar la calculadora, primero que nada correremos 17 push botton, el cual editaremos de tal manera que contengas las instrucciones

correspondientes para la utilización de nuestra calculadora:

Page 3: prac calculadora

Ingeniería Electromecánica Salomón Durán

Ya teniendo nuestros componentes damos click en la opción de ejecutar, este nos abrirá un nuevo documento en terminación (.m) en el cual editaremos nuevamente cada push botton, colocándole la instrucción

correcta para la ejecución de nuestra calculadora, quedando de la siguiente forma:

function varargout = calcu3(varargin)% CALCU3 M-file for calcu3.fig% CALCU3, by itself, creates a new CALCU3 or raises the existing% singleton*.%% H = CALCU3 returns the handle to a new CALCU3 or the handle to% the existing singleton*.%% CALCU3('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in CALCU3.M with the given input arguments.%% CALCU3('Property','Value',...) creates a new CALCU3 or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before calcu3_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to calcu3_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 calcu3 % Last Modified by GUIDE v2.5 12-Nov-2010 09:19:07 % Begin initialization code - DO NOT EDIT

Page 4: prac calculadora

Ingeniería Electromecánica Salomón Durán

gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @calcu3_OpeningFcn, ... 'gui_OutputFcn', @calcu3_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 calcu3 is made visible.function calcu3_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 calcu3 (see VARARGIN) % Choose default command line output for calcu3handles.output = hObject; % Update handles structureguidata(hObject, handles); % UIWAIT makes calcu3 wait for user response (see UIRESUME)% uiwait(handles.figure1);background = imread('background.jpg'); %Leer imagenaxes(handles.background); %Carga la imagen en backgroundaxis off;imshow(background); %Presenta la imagen% Choose default command line output for Sumadorahandles.output = hObject;% Update handles structureguidata(hObject, handles); % --- Outputs from this function are returned to the command line.function varargout = calcu3_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 structurevarargout{1} = handles.output; % --- Executes on button press in uno.function uno_Callback(hObject, eventdata, handles)% hObject handle to uno (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'1');set(handles.text1,'String',textString) % --- Executes on button press in cuatro.function cuatro_Callback(hObject, eventdata, handles)% hObject handle to cuatro (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB

Page 5: prac calculadora

Ingeniería Electromecánica Salomón Durán

% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'4');set(handles.text1,'String',textString) % --- Executes on button press in siete.function siete_Callback(hObject, eventdata, handles)% hObject handle to siete (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'7');set(handles.text1,'String',textString) % --- Executes on button press in suma.function suma_Callback(hObject, eventdata, handles)% hObject handle to suma (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'+');set(handles.text1,'String',textString) % --- Executes on button press in mult.function mult_Callback(hObject, eventdata, handles)% hObject handle to mult (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'*');set(handles.text1,'String',textString) % --- Executes on button press in Allclear.function Allclear_Callback(hObject, eventdata, handles)% hObject handle to Allclear (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)ini=char(' ');set(handles.text1,'String',ini); % --- Executes on button press in dos.function dos_Callback(hObject, eventdata, handles)% hObject handle to dos (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'2');set(handles.text1,'String',textString) % --- Executes on button press in tres.function tres_Callback(hObject, eventdata, handles)% hObject handle to tres (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'3');set(handles.text1,'String',textString) % --- Executes on button press in cinco.function cinco_Callback(hObject, eventdata, handles)% hObject handle to cinco (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'5');set(handles.text1,'String',textString) % --- Executes on button press in seis.

Page 6: prac calculadora

Ingeniería Electromecánica Salomón Durán

function seis_Callback(hObject, eventdata, handles)% hObject handle to seis (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'6');set(handles.text1,'String',textString) % --- Executes on button press in ocho.function ocho_Callback(hObject, eventdata, handles)% hObject handle to ocho (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'8');set(handles.text1,'String',textString) % --- Executes on button press in nueve.function nueve_Callback(hObject, eventdata, handles)% hObject handle to nueve (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'9');set(handles.text1,'String',textString) % --- Executes on button press in resta.function resta_Callback(hObject, eventdata, handles)% hObject handle to resta (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'-');set(handles.text1,'String',textString) % --- Executes on button press in cero.function cero_Callback(hObject, eventdata, handles)% hObject handle to cero (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'0');set(handles.text1,'String',textString) % --- Executes on button press in div.function div_Callback(hObject, eventdata, handles)% hObject handle to div (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=strcat(textString,'/');set(handles.text1,'String',textString) % --- Executes on button press in igual.function igual_Callback(hObject, eventdata, handles)% hObject handle to igual (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString=get(handles.text1,'String');textString=eval(textString,'1');set(handles.text1,'String',textString) % --- Executes on button press in info.function info_Callback(hObject, eventdata, handles)% hObject handle to info (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

Page 7: prac calculadora

Ingeniería Electromecánica Salomón Durán

msgbox('Calculadora Sencilla. Por: Salomon Duran H','Acerca de...');

Finalmente al tener terminado de editar cada elemento ahora si gui para observar si se ejecuta de la manera adecuada nuestra calculadora:

Conclusión

En esta práctica se pudo conocer la aplicación de interfaz grafica en matlab, aplicando la programación en gui para la realización de diversos programas gráficos y visuales.