"dfgdg dfgdfg" <email@example.com> wrote in message
> I'm an old C# user and new matlab gui user.I can define a global variable
> easily in C# which can be recognized by all program not one function.
> I have tried some step for this operation;
> 1-I have defined the variable;
> global x;
If you MUST use global variables, then you need to declare the variable as
global in EACH AND EVERY FUNCTION that you want to be able to access the
variable from the global workspace. However, using global variables is
discouraged as they can cause problems that are difficult to diagnose and
> 2-Then I wrote these code under; "function varargout = filename(varargin)"
> which is located at top.It doesnt work.I couldn't use variable under other
That's correct. Each function has its own workspace, and cannot (normally)
access other function workspaces.
> 3-Then I have tried to write this code under;
> "function filename_OpeningFcn(hObject, eventdata, handles,
> But It didn't work again.
> 4-Then I have tried to write this code under;
> "function varargout = MH_OutputFcn(hObject, eventdata,
> But It didn't work again and again.
> How can I fix this problem?Is there anyway for Matlab Gui?
I recommend using the techniques described in the documentation to share
data amongst your GUI callback functions.
If you are using GUIDE:
If you are not using GUIDE:
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on