On Wed, 24 Jan 2007 10:51:50 -0800, rohan wrote:
> Where can I define global variables in Matlab ( GUI application) ? I
> mean that I would like to have
> variable which is seen inside every function(
> Listbox_callback,pushbutton_Callback etc...)
> In other languages (Delphi,Visual C) there are places where global
> variables are put and can be used by the whole application, but I have
> no idea how it is in Matlab. I'll be grateful for advice.
> Regards, Piotr W.
Don't use global variables for this. Either attach your variables to the
handles-structure ( it's passed to your functions anyway). Then use
guidata to store the handles-structure:
% now the variable handles.myVar is available to any function that you
pass handles into.
Another option is to use setappdata and getappdata. It is my strong belief
that both methods presented above are better than using global variables.
If you still decide to use global variables, then the only trick is to
define the variables as gloabal in any function where you wish to use the