Você está na página 1de 35

Guide

Prof. Cludio A. Fleury


Abr - 2009
Interface Grfica para
Aplicaes Matlab
Iniciando
Objetos de Controle
Push Button
Radio Button
Checkbox
Toggle Button
List Box
Axes
Slider
Edit Text
Popup Menu
Static Text (Label)
Frame
P.O.O.
Objetos
Propriedades
Aes
estofamento
cor
material
design
tamanho
Propriedades dos Objeto
Propriedades dos Objeto
P.O.O.
Enable
Visible
on
off
inactive
on
off
P.O.O.
P.O.O.
WindowStyle
modal normal
Resize
modal normal
on off
P.O.O. - Aes
Ao disparada pelo controle ao ser clicado:
Alteraes em Tempo de
Execuo
Alteraes em Tempo de
Execuo
get(handles.edit1,'String')
Tag
Alteraes em Tempo de
Execuo
set(handles.text1,'String',C)
Interface Grfica para Usurio*
* GUI Graphical User Interface
Criador de GUI
Carregando o guide:
Criador de GUI
Criador de GUI
Criando os Controles
Componentes
2 Edit Text
4 Static Text 4 Static Text
1 Pushbutton
Interface at agora!
Ajustando as Propriedades
Interface at agora!
Melhorando o aspecto visual da interface:
Ajustando as Propriedades
Interface at agora!
Save it! Save it!
Acrescentando Cdigo
Funes callback
Acrescentando Cdigo
Programa para os campos de textos
function input1_editText_Callback(hObject, eventdata, handles)
% hObject - a ala (handle) para input1_editText (ver GCBO)
% eventdata - reservado a ser definido no futuro do MATLAB % eventdata - reservado a ser definido no futuro do MATLAB
% handles estrutura com alas e dados do usurio (ver GUIDATA)
% Dicas:
%
% get(hObject,'String') retorna o contedo de input1_editText c/ texto
% str2double(get(hObject,'String')) retorna contedo de input1_editText
% como um double
Acrescentando Cdigo
Programa para os campos de textos
function input1_editText_Callback(hObject, eventdata, handles)
% armazena o contedo de input1_editText como uma string. Se a string
% no for um nmero ento a entrada ser esvaziada
input = str2num(get(hObject,'String')); input = str2num(get(hObject,'String'));
% verifica se a entrada est vazia. Se sim, input1_editText recebe zero
if (isempty(input))
set(hObject,'String','')
msgbox(Digite um valor numrico, Ateno);
end
guidata(hObject, handles);
Acrescentando Cdigo
Programa para o boto
% --- Executes on button press in add_pushbutton.
function add_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to add_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a = get(handles.input1_editText,'String');
b = get(handles.input2_editText,'String');
% a and b are variables of Strings type, and need to be converted
% to variables of Number type before they can be added together
total = str2num(a) + str2num(b);
c = num2str(total);
% need to convert the answer back into String type to display it
set(handles.answer_staticText,'String',c);
guidata(hObject, handles);
Desligando Comentrios
Automticos
Executando a GUI
Executando a GUI
Primeiro Programa Matlab com GUI
Exerccio
Fazer um programa Matlab com GUI para plotar o grfico de vrios
sinais e respectivos espectros, conforme a figura:
Dvidas
[time,number,pressure,raininput] = textread(rain.txt,'%s %d %f %f,'delimiter,',,'headerlines,4);
Thats all folks!
Prof. Cludio A. Fleury Abr/2009
prof.claudio.2008.2@gmail.com

Você também pode gostar