Help using guidata in a script

1 visualización (últimos 30 días)
Julian
Julian el 30 de Ag. de 2018
Comentada: Julian el 31 de Ag. de 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!

Respuesta aceptada

OCDER
OCDER el 30 de Ag. de 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
  1 comentario
Julian
Julian el 31 de Ag. de 2018
Thank you, that was very helpful!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by