






Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!







DEI - Univ. Padova (Italia)
Blank GUI
DEI - Univ. Padova (Italia)
DEI - Univ. Padova (Italia)
DEI - Univ. Padova (Italia)
Quando si salva la GUI, GUIDE crea automaticamente un M-file che può contenerediverse sezioni: Commenti
: mostrati nella command window in risposta al comando help.
Inizializzazione della GUI
: Alcune istruzioni di inizializzazione create da GUIDE.
Questo codice non deve essere modificato.
Opening function
: qui
si
possono
inserire
le
inizializzazioni
da
eseguire
prima
che
DEI - Univ. Padova (Italia)
Opening function
: qui
si
possono
inserire
le
inizializzazioni
da
eseguire
prima
che
l’utente inizi ad interagire con la GUI.
Output function
: restituisce outputs alla command line dopo l’esecuzione della
opening function
Component and figure callbacks
: funzioni che controllano il comportamento del pannello principale della GUI e dei sui varicomponenti. Permettono di gestire eventi relatividegli elementi e della GUI stessa.
Utility/helper functions
: funzioni varie non direttamente associate ad un evento.
function
input1_editText_Callback(hObject, eventdata, handles)
% store the contents of input1_editText as a string. if the string% is not a number then input will be empty input = str2num(get(hObject,'String')); % checks to see if input is empty. if so, default input1_editText to zero
Esempio di programmazione di un edit_textbox
DEI - Univ. Padova (Italia)
% checks to see if input is empty. if so, default input1_editText to zero if
(isempty(input))
set(hObject,
'String'
, '0'
)
end guidata(hObject, handles);
% --- Executes on button press in add_pushbutton. function
add_pushbutton_Callback(hObject, eventdata, handles)
% get data from the field “String” of the element with tag “input1_editText” a = get(handles.input1_editText,
'String'
);
% get data from the field “String” of the element with tag “input2_editText” b = get(handles.input2_editText,
'String'
);
Esempio di programmazione di un push_button
DEI - Univ. Padova (Italia)
% 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 data to the field “String” of the element with tag “answer_staticText” set(handles.answer_staticText,
'String'
,c);
guidata(hObject, handles);