How to access GUI workspace?
조회 수: 11 (최근 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!