Borrar filtros
Borrar filtros

passing variables from gui to another m file

1 visualización (últimos 30 días)
eliza
eliza el 24 de Feb. de 2012
Editada: Ben el 24 de Oct. de 2013
hi
i have a gui interface whereby there is a drop down list to choose which data set you want. i have another my file that is dependent on the users choice of the dataset. how do i link the data from gui to another my file.
should i create a function
mydata=getdatamatirx(handles)
mydata = handles.data

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 24 de Feb. de 2012
FAQ This should help.
  5 comentarios
eliza
eliza el 27 de Feb. de 2012
what i am trying to do is:
from the gui the proper matrix data is extracted and then have to link that data to another m file. i am having trouble extracting the matrix to the other m file.
is there away to do this without having to define the matrices as global variables?
Sean de Wolski
Sean de Wolski el 27 de Feb. de 2012
Yes, did you read the FAQ? use setappdata to store it and getappdata to retrieve it.
■Storing data in the application workspace using the SETAPPDATA and GETAPPDATA functions.
% Do this to save variables to your figure's workspace.
% handles.GUIHandle is the "Tag" property of your main GUI figure.
% Double-click figure to bring up the "Property Inspector" in GUIDE.
setappdata(handles.GUIHandle, 'yourVariable', yourVariable)
% Do this to retrieve variables from your figure's workspace.
yourVariable = getappdata(handles.GUIHandle , 'yourVariable')
% Do this to remove what you saved from your figure's workspace.
rmappdata(handles.GUIHandle, 'yourVariable')
You could also set to the root directory, i.e. 0., that way stuff is stored even after you close the GUI.
%Set
setappdata(0,'myStuff',stuff);
%Extract
mystuff = getappdata(0,'mystuff')

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by