How to access GUI workspace?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I'm quite sure matlab has a separate workspace that store all variable for GUI. Does any1 know how to access the workspace?
function button1_Callback(hObject, eventdata, handles)
% hObject handle to Quit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global a;
imshow(a,'parent',handles.im1);
I cleared every variable with the function 'clear'. Then i run the GUI and press a button with above code. The GUI is able to display image 'a' that was called previously.
0 comentarios
Respuestas (3)
Yoav Livneh
el 13 de Jul. de 2011
CLEAR only clears the current workspace, which is usually 'base'. Your GUI is run from a separate function which has its own workspace, usually the same name as the function.
If you want to access the GUI function variables just put a break point somewhere in the function and then you could examine the variables in that workspace.
You could also use the function ASSIGNIN to send variables to your 'base' workspace and examine them that way.
0 comentarios
Image Analyst
el 13 de Jul. de 2011
See the FAQ for several ways to do it: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F
0 comentarios
Walter Roberson
el 13 de Jul. de 2011
MATLAB does not have "a separate workspace that store all variable for GUI." It has a "base workspace", it has an implicit "global workspace" (for global variables), and it has workspaces for each function (including anonymous functions).
Your issue has to do with it being a global variable you are trying to clear. From the documentation:
clear global name removes the global variable name. If name is global, clear name removes name from the current workspace, but leaves it accessible to any functions declaring it as global. Use clear global name to remove a global variable completely.
0 comentarios
Ver también
Categorías
Más información sobre Migrate GUIDE Apps 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!