sharing data across GUI

2 visualizaciones (últimos 30 días)
akshay raj
akshay raj el 25 de En. de 2015
Comentada: Image Analyst el 25 de En. de 2015
hi,
So i tried to share GUI data using setappdata and getappadata. for example lets consider this
matfile1.m
h = EmotivEEG;
h.Run
for k = 1:4
out(:,:,k) = h.data + rand(1);
setappdata(0,'eegData', out(:,:,k));
pause(0.5);
end
h.delete
so the above file creates a 128x14 matrix every o.5 seconds and store it in eegData
matfile2.m
some_var = getappdata(0,'eegdata')
plot(some_var)
this seems to work but not while in the loop, if i ask it to plot it i get this error
Error using setappdata
Too many output arguments.
Error in eeg_live>eeg_live_OpeningFcn (line 83)
lmno = setappdata(0,'eegData');
Error in gui_mainfcn (line 221)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
Error in eeg_live (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in Neucube>activation_Callback (line 3963)
eeg_live
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in Neucube (line 49)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)Neucube('activation_Callback',hObject,eventdata,guidata(hObject))
Error using pause
Error while evaluating uicontrol Callback

Respuestas (1)

Image Analyst
Image Analyst el 25 de En. de 2015
Editada: Image Analyst el 25 de En. de 2015
When it says something like that, that pause() is wrong but you know it's right - then it's time to look at a line above and see if something is messed up. So look at this line:
setappdata(0,'eegData', out(:,:,k);
Notice two errors there. First, you're missing a right parenthesis and so that's probably the cause of your error with pause. The second is that you're repeatedly overwriting the same eegData variable, so it will end up with only the value out(:,:, 4). None of the other matrices for other values of k (1 through 3) are saved. Well they are, but only temporarily until they get overwritten the next iteration.
  2 comentarios
akshay raj
akshay raj el 25 de En. de 2015
sorry that was a typo, and the update function is taken care of in EmotivEEG.m file, Ok i am able to run the code and its working like I wanted, now what if i want to plot it simultaneously, for example.
matfile1.m
h = EmotivEEG;
h.Run
for k = 1:4
out(:,:,k) = h.data + rand(1);
plot(out(:,:,k))
setappdata(0,'eegData', out(:,:,k));
pause(0.5);
end
h.delete
matfile2.m
some_var = getappdata(0,'eegdata')
plot(some_var)
so when i am opening matfile2.m, the plotting pauses in matfile1.m.
any idea on how to plot the data simultaneously ?
Image Analyst
Image Analyst el 25 de En. de 2015
OK, you've fixed that, and now it says:
Error using setappdata
Too many output arguments.
and yet you're doing this in eeg_live_OpeningFcn() according to the error message:
lmno = setappdata(0,'eegData');
Why are you trying to set the output of setappdata() to something when the help says you can't do that? Of course that's not the code you posted so this shows why it's always best to post the full error message like you did (yay!), so we can see the actual line of code instead of the one the poster tried to remember. It pays to read the error messages closely - maybe you would have noticed that the line of code it errored on was not the one you thought it was.

Iniciar sesión para comentar.

Categorías

Más información sobre App Building 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