From: Athanasios on 12 Feb 2010 17:20 Hi, i cant find the way to access the variables from the base workspace when i run a gui,.... Lets say that i want to access the values of the variables a and b from workspace so that the user can see them and set a value with a slider that afterwards will be saved in a variable called c in the base workspace...Any suggestions?
From: ImageAnalyst on 12 Feb 2010 17:25 Have you looked at the evalin() function? But I don't think anyone recommends that. Why don't you try passing in the variables properly via the argument list? Or use getappdata(), setappdata()? Another unfavored option is to use the "global" keyword.
From: Athanasios on 13 Feb 2010 12:30 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <982691ff-095c-4dd8-bf6a-de5214a1d0d4(a)g23g2000vbl.googlegroups.com>... > Have you looked at the evalin() function? > But I don't think anyone recommends that. Why don't you try passing > in the variables properly via the argument list? Or use getappdata(), > setappdata()? Another unfavored option is to use the "global" keyword. You mean that the preffered way is to pass the variables via the arguments list... The way is done with functions i assume.. In the case of the gui that i have something like this function varargout = MYGUI(varargin) should i replace the "varargin" like i would do with any other function?? And what do i have to do with the other instances of "varargin" that i find in the code below?: gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @MYGUI_OpeningFcn, ... 'gui_OutputFcn', @MYGUI_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end Thanx in advance..
From: ImageAnalyst on 13 Feb 2010 13:05 You can leave it as varargin. Then just use deal() to send it out to various variables inside if you want, or else just assign them one at a time.
From: Athanasios on 13 Feb 2010 13:34
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <76469a1d-0c26-4907-b076-4aed09dbf450(a)o36g2000vbl.googlegroups.com>... > You can leave it as varargin. Then just use deal() to send it out to > various variables inside if you want, or else just assign them one at > a time. hmm i'm afraid i dont get it... Lets review what i want to help you understand in case i have explained something wrong.. Lets say i have a bunch of m files that when they complete execution they leave with the variables a and b in the base workspace.. Then i want to run the gui and to read these variables so the user can see them and drag a slider to a desired vakue that after the execution of the gui will be saved in a c variable that belongs to the base workspace... It seem that is simple... but i am missing something with the way of manipulating guis and base workspace... |