フィルターのクリア

passing variables from gui to another m file

1 回表示 (過去 30 日間)
eliza
eliza 2012 年 2 月 24 日
編集済み: Ben 2013 年 10 月 24 日
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

採用された回答

Sean de Wolski
Sean de Wolski 2012 年 2 月 24 日
FAQ This should help.
  5 件のコメント
eliza
eliza 2012 年 2 月 27 日
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 2012 年 2 月 27 日
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')

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by