Save Data Matrix GUI

1 visualización (últimos 30 días)
Andreas
Andreas el 1 de Jul. de 2013
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)

Respuesta aceptada

Jan
Jan el 1 de Jul. de 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

Más respuestas (1)

Andreas
Andreas el 1 de Jul. de 2013
Editada: Andreas el 1 de Jul. de 2013
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?

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects 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