3 views (last 30 days)
Abdullah Tahir
Abdullah Tahir on 4 Jun 2012
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.
Abdullah Tahir
Abdullah Tahir on 25 Jul 2012
Global does not work here. Global is efficient to access variables in different functions in GUI's m-file. But it is unable to export variables to command window.

Sign in to comment.

Accepted Answer

Luffy on 11 Jul 2012
Edited: Ned Gulley on 11 Jul 2012
If you want to access data that is in base workspace in your gui functions, use
v = evalin('base','name of variable u want to access');
% the variable's data is now stored in v.
If u want to save data of ur gui work space to base, use
assignin('base','name of variable u want to save','value of variable');

More Answers (1)

Caleb on 16 Jul 2012
% Intial value of a
a = 2;
setappdata(0,'a',a+1) % Put this part within the callback function of the pushbutton
% Get the value of a


Find more on Migrate GUIDE Apps in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!