Save Data Matrix GUI

1 回表示 (過去 30 日間)
Andreas
Andreas 2013 年 7 月 1 日
Hi all! I have a list box that I am able to choose various elements,push a button,erase the selected elements from my first listbox and then I want to save them in a matrix so I can pass it to another listbox.Is there any way I can do that without globals?I am newbie to GUIDE so please excuse if this seems dumb. Here's a piece of code. Thank you all
function pushbutton3_Callback(hObject, eventdata, handles)%Data input
handles.fileName=uigetfile('*.xls');
if handles.fileName == 0
return
end
[handles.Values,handles.Headers]=xlsread(handles.fileName);
handles.Names=handles.Headers(1,2:end)
set(handles.nAssets,'String',handles.Names,'Value',1)
handles.Dates=handles.Headers(2:end,1)
handles.Values=handles.Values(:,3:end)
guidata(hObject,handles);
function in_Callback(hObject, eventdata, handles)
List = handles.nAssets;%nAssets is the listbox' name
indexed = get(List,'value');
Names = get(List,'String');
handles.newNames=Names(indexed)%saving the names selected
Names(indexed) = [];
set(handles.nAssets,'String',Names,'Value',1)
guidata(hObject,handles)

採用された回答

Jan
Jan 2013 年 7 月 1 日
You can use guidata to store values in the figure's ApplicationData. This is not as global as global, but local to the current figure. An equivalent method is storing data in the figure's 'UserData'.
See:
doc guidata

その他の回答 (1 件)

Andreas
Andreas 2013 年 7 月 1 日
編集済み: Andreas 2013 年 7 月 1 日
I didn't quite understood your answer,however thank you very much for your reply.In case my question was unclear,what I want to do is to save the previously selected data in a matrix and save them with the newly clicked ones.Sorry,I'm a complete newbie in GUI..Could you please give an example?

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by