이전 댓글 표시
hi... Can you please tell me how to access GUI (Graphical User Interface) variables in command window? Actually I have declared a button in the GUI and before this button a code runs "a=2" after pressing this button, I want to increment in this variable "a" in the command window. How may I access this variable in command window. Help me, thanks.
댓글 수: 3
Walter Roberson
2012년 6월 4일
I am confused. Are you trying to use the command window to control variables in the GUI, or are you trying to use the GUI to control the command window?
Dmitry
2012년 7월 11일
If you want to get access to variable "a" from workspace in button callback you should declare "a" as global: "global a; a=2;". Then in button callback: "global a; a=a+1"; But if you use GUIDE I suppose you should not use command window, it's inconvenient.
Abdullah Tahir
2012년 7월 25일
채택된 답변
추가 답변 (1개)
Caleb
2012년 7월 16일
0 개 추천
% Intial value of a
a = 2;
setappdata(0,'a',a)
%%%%%%%%%%%%%
setappdata(0,'a',a+1) % Put this part within the callback function of the pushbutton
% Get the value of a
getappdata(0,'a')
카테고리
도움말 센터 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!