Curso MatLab UNI

UNIVERSIDAD NACIONAL DE INGENIERIA FACULTAD DE INGENIERIA ELECTRICA Y ELECTRONICA Interfaces Gráficas en Matlab GUIDE P

Views 69 Downloads 3 File size 2MB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

UNIVERSIDAD NACIONAL DE INGENIERIA FACULTAD DE INGENIERIA ELECTRICA Y ELECTRONICA

Interfaces Gráficas en Matlab GUIDE Profesor: Klebes Raúl Arias Quispe 04 de marzo del 2012

Interfaces Gráficas con MATLAB -GUIDE Las interfaces gráficas de usuario (GUI - Graphical User Interface), es la forma en que el usuario interact+ua con el programa o el sistema operativo de una computadora. Una GUI contiene diferentes elementos gráficos tales como: botones, campos de texto, menús, gráficos , etc.

Existen diferentes lenguajes de programación que permiten crear una GUI tales como: C, Visual Basic, TK, etc. Sólo por mencionar algunos. Todos ellos permiten usar diferentes controles y maneras de programarlos . Matlab nos permite usar GUIs de una manera muy sencilla usando GUIDE (Graphical User Interface Development Enviroment).

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE Probar con valores negativos cambiando las propiedades max y min

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE Push Button Radio Button

Edit Text

Toggle Button Checkbox Static Text

Slider Frame List Box Axes

Popup Menu

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Visible

Enable

on off on off inactive

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE Utilizando llamada funciones En este caso estamos llamando a la función factorial, reordar que debe estar en la misma carpeta de trabajo

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE Para salir de una ejecución mediante botón function botonsalida_Callback(hObject, eventdata, handles) opc=questdlg( '¿Desea salir del programa?' ,... 'SALIR','Si','No','No'); if strcmp(opc,'No') return; else delete(handles.figure1); end

Interfaces Gráficas con MATLAB -GUIDE Uso del Litbox

Interfaces Gráficas con MATLAB -GUIDE

: :

Interfaces Gráficas con MATLAB -GUIDE Abrir un archivo

uigetfile, abre un cuadro de diálogo estándar para recuperar archivos

winopen, abre un archivo en windows

Interfaces Gráficas con MATLAB -GUIDE Para abrir un archivo del tipo imagen

Para abrir un archivo del tipo documento

Interfaces Gráficas con MATLAB -GUIDE Programa de funciones trigonométricas:

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE Calculadora 1

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) a=str2num(get(handles.edit1,'string')); b=str2num(get(handles.edit2,'string')); c=a+b; set(handles.text3,'string',num2str(c));

Interfaces Gráficas con MATLAB -GUIDE Calculo del Combinatorio

Interfaces Gráficas con MATLAB -GUIDE switch valor_pum case 2 %Adquirir valores del GUI % leer y mostrar valor=get(handles.et1,'String'); set(handles.st2,'String',valor); vector=str2num(valor); % from char to num set(handles.st3,'String','Opcion 1');

% Obtener la info de las posiciones del vector. % [10,2,0,.2,-3,3] fc=vector(1,1); A=vector(1,2); xmin=vector(1,3); xmax=vector(1,4); ymin=vector(1,5); ymax=vector(1,6); % Exportar a Workspace, se puede tambien importar del WS al GUI con % EVALIN(WS,'expression'). assignin('base','fc',fc) assignin('base','A',A) % Grafica en la Opción 1 x=-5:1/1000:5; y=sin(2*pi*fc*x); handles.g1 = plot(handles.axes1,x,y,'b-+'); set(handles.axes1, 'xgrid', 'on' , 'ygrid', 'on','Xlim',[xmin xmax],'Ylim',[ymin ymax]);

case 3 set(handles.st3,'String','Opcion 2'); x=0:0.00001:0.0625; y=square(2*pi*30*x); handles.g2=plot(handles.axes2,x,y,'g-+'); set(handles.axes2,'xgrid','on','ygrid','on'); otherwise set(handles.st3,'String','Opcion 3'); axes(handles.axes1); i1=imread('1.bmp'); imshow(i1); axes(handles.axes2); i2=imread('2.jpg'); imshow(i2); end

Interfaces Gráficas con MATLAB -GUIDE Calculadora 2

Agregar funciones trigonométricas y exponenciales

Interfaces Gráficas con MATLAB -GUIDE % --- 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) % v1=get(handles.pushbutton1,'string'); % set(handles.text1,'string',v1); textstr=get(handles.text1,'string'); textstr=strcat(textstr,'1'); set(handles.text1,'string',textstr); function pushbutton15_Callback(hObject, eventdata, handles) % hObject | handle to pushbutton15 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) textstr=get(handles.text1,'string'); textstr=eval(textstr); set(handles.text1,'string',num2str(textstr));

function pushbutton14_Callback(hObject, eventdata, handles) set(handles.text1,'string',' ');

Interfaces Gráficas con MATLAB -GUIDE Corriendo Simulink desde GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Interfaces Gráficas con MATLAB -GUIDE Corriendo Simulink desde GUIDE

Interfaces Gráficas con MATLAB -GUIDE

Gracias por su atención !!!