Help using guidata in a script

1 visualizzazione (ultimi 30 giorni)
Julian
Julian il 30 Ago 2018
Commentato: Julian il 31 Ago 2018
Hi everyone,
i have a quick question about the use of guidata.
Say i have a script like that:
random code [handles, movie] = timelapse(selection, handles] guidata(gcbo, handles) random code
do i really need to use guidata in this case or does my function already return the current handle structure? Thank you guys!

Risposta accettata

OCDER
OCDER il 30 Ago 2018
If you pass handles as input and also output, you don't need guidata
Use guidata only to store/retrieve the GUI's data.
function [handles, movie] = myFcn(CurFigHandle)
handles = guidata(CurFigHandle); %In this case, use guidata to retrieve handles, since it was not an input
movie = handles.movie;
function [handles, movie] = myFcn(handles)
movie = handles.movie;
%No guidata required, since handles was passed as the input.
In GUIDE, the handles is pretty much always passed as the 3rd input to a callback function, so no need to use guidata to "retrieve" handle. You do need to use guidata to "store" any changes to handles though.
function pushbutton_callback(hObject, events, handles)
movie = handles.movie;
handles.movie = movie(1:end-1); %Changes made!
guidata(hObject, handles); %save modified handles

Più risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by