Prev: Accessing Metastock database from ML
Next: Discrete-time, second-order section, direct-form II filter, using 16 bits integer data type
From: Jason on 15 Jun 2010 12:05 Gerbil Gerbil <gerbilgerbilgerbil(a)gmail.com> wrote in message <09c3427d-2f53-4b7e-953c-d36950f7dfa4(a)k39g2000yqb.googlegroups.com>... > Hi Everyone, > > I've been tinkering with this for the past few days and not getting > anywhere. Since posting, I've spent a lot of time trying to update my > GUIDE GUI with uiwait() where it tells me to put it in the function, > and putting uiresume() in various places. I thought it might make some > sense to mess around with putting varargout as one of the returns for > my last callback, since it seems to be getting the values I'm trying > to pass it, but that just makes the program error out. I'd really > appreciate any help I can get, so I can at least stop the random > google searches that only seem to lead to irrelevant matlab help > pages. Here's the rest of my earlier post: > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > I'm trying to design a GUI that I can run from a script, returning the > values entered by the user back to the script for further processing. > > My problem is that I can't seem to get my values back through their > varargout. I've tried tinkering with the output function, but it > hasn't fixed anything. I've tried putting something in here to test > the output, and it successfully updates handles.output to 'test > output', so I know the problem isn't that it's not returning it: > > > function varargout = myFunction_OutputFcn(hObject, eventdata, handles) > > handles.output = 'test output'; % to test the output > > varargout{1} = handles.output; > > It works, but if I try to update handles.output by updating the > handles variable using my other callbacks, it doesn't seem to be > getting back to the main function: > > > function varargout = myGUI(varargin) > > It seems to me that the main function (myGUI) expects a return from > myFunction_OutputFcn before any of my other callbacks can do their > updating of the variables by the user, so it's tripping over trying to > provide a handles.output that isn't being provided by the handles > input. > > I know that the rest of handles being passed between the callbacks are > working, since I am able to display the updated variables in a msgbox > triggered by a user pressing a push button. I'm just not entirely sure > how it is that all my other functions can pass handles to each other > perfectly well, while this output function isn't getting updated in > the same way. > > I'd really appreciate any advice on this, > > Laura Here's a similar thing I did that might help: Define a global variable in the GUI calling script and in the GUI script. Let's say you want to see a button push result. Here is a sample calling script: function [ buttonpush ] = tester %%%% Try to pass back button push info in global %%%% global buttonpush %Run GUI Test_button; end Build GUI with guide then modify these functions. In the GUI script: function Test_button_OpeningFcn(hObject, eventdata, handles, varargin) .... the usual stuff ... uiwait(hObject); %% wait for button push to happen before returning function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %%%% Pass back button push info in global %%%% global buttonpush buttonpush = 'accept'; guidata(hObject, handles); % ------ Close after button pushed -------- % delete(handles.figure1) Lastly, do not try to pass back handle since you deleted the figure already: function varargout = Test_button_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure %%%Don't need these now %guidata(hObject, handles); %varargout{1} = handles.output From command line type: > a=tester Hope this helps. -Jason |