How can I save data in a GUI?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all! I'm implementing a GUI with GUIDE but I have some troubles. The first problem is to load data from the workspace. Data is a struct. This is the code I've writenn:
EEGHere = evalin('base','EEG'); DataHere = EEGHere.data;
is it right? Can I use the DataHere inside GUI function?
The second problem is that I want to save in a row vector, a row from matrix DataHere. The row vector to save, is the return of an edit in GUI (users write a number that correspond to a row of matrix). I've tried to write this command:
channel = get(handles.editchannel); signal = DataHere(channel,:);
but displays this error ??? Error using ==> subsindex Function 'subsindex' is not defined for values of class 'struct'.
How can I do?
0 comentarios
Respuesta aceptada
Kevin Claytor
el 19 de Jul. de 2012
A couple of things. You seem to be on the right track with your data loading;
EEGHere = evalin('base','EEG'); DataHere = EEGHere.data;
But you may want to store it in handles;
handles.DataHere = DataHere; guidata(hObject, handles); % Update handles
because the GUI is comprised of a bunch of different functions (callbacks, user-defined functions, etc.), and DataHere is only available to the function in which it is defined (unless you explicitly pass it to another function). On the other hand, handles is stored in the GUI figure, and all the callbacks usually have access to it. You just have to make sure to keep it up-to-date with the guidata command. That is, if you change the value of handles.DataHere in a subfunction, and want to keep that value changed in the function that called it, you'll have to run guidata(...) within the subfunction.
Now this command;
channel = get(handles.editchannel); signal = DataHere(channel,:);
is about halfway there, get(handles.editchannel), returns a structure with all the properties from editchannel. I think you want a specific property, maybe;
channel = get(handles.editchannel,'Value');
Now if editchanel is an editbox, this will return a string not a number, so you'll have to use str2num() on the output as well.
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Workspace Variables and MAT-Files 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!