Save Data Matrix GUI
5 views (last 30 days)
Show older comments
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)
0 Comments
Accepted Answer
Jan
on 1 Jul 2013
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
0 Comments
More Answers (1)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!