How to access GUI workspace?
13 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(3 个)
Yoav Livneh
2011-7-13
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 个评论
Image Analyst
2011-7-13
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 个评论
Walter Roberson
2011-7-13
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!