Azzera filtri
Azzera filtri

passing variables from gui to another m file

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Sean de Wolski
Sean de Wolski il 24 Feb 2012
FAQ This should help.
  5 Commenti
eliza
eliza il 27 Feb 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 il 27 Feb 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')

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by