Escolar Documentos
Profissional Documentos
Cultura Documentos
Fleury
Abr - 2009
Guide
Interface Grfica para o Matlab
Fonte: blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners
Criador de GUI
Carregando o guide:
Criador de GUI
Criador de GUI
Criando os Controles
Componentes
2 Edit Text
4 Static Text
1 Pushbutton
Interface at agora!
Ajustando as Propriedades
Interface at agora!
Ajustando as Propriedades
Melhorando o aspecto visual da interface:
Interface at agora!
Save
Save it!
it!
Acrescentando Cdigo
Funes callback
Acrescentando Cdigo
Programa para os campos de textos
function
function input1_editText_Callback(hObject,
input1_editText_Callback(hObject, eventdata,
eventdata, handles)
handles)
%% hObject
armazena- o contedo
a ala (handle)
de input1_editText
para input1_editText
como uma string.
(ver GCBO)
Se a string
%% eventdata
no for um- nmero
reservado
ento
aa ser
entrada
definido
ser no
esvaziada
futuro do MATLAB
%input
handles
= str2num(get(hObject,'String'));
estrutura com alas e dados do usurio (ver GUIDATA)
% Dicas:
%% verifica se a entrada est vazai. Se sim, input1_editText recebe zero
%if get(hObject,'String')
(isempty(input))
retorna o contedo de input1_editText c/ texto
% str2double(get(hObject,'String'))
set(hObject,'String','0')
retorna contedo de input1_editText
%end
como um double
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
% 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
Exerccio
Fazer um programa Matlab com GUI para plotar o grfico de vrios
sinais e respectivos espectros, conforme a figura:
Dvidas