a GUI keeps popping out after close command
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello.
I have 2 GUIs (figure1 and figure2). I pass 1 data from figure1 to figure2 via a pushbutton in figure1. The input is a double type.
function pushbutton4_Callback(hObject, eventdata, handles)
figure2({input})
In figure2 opening function, I have
function figure2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to figure2 (see VARARGIN)
% Choose default command line output for figure2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes figure2 wait for user response (see UIRESUME)
% uiwait(handles.figure2);
stageNo = varargin{1};
In figure2, I also created a pushbutton to close figure2 after storing some data.
function cancelbutton_Callback(hObject, eventdata, handles)
user_response = modaldlg1('Title','Confirm Close');
switch user_response
case {'No'}
case 'Yes'
close(figure2)
end
However, everytime I click the cancelbutton, figure2 pops up again and gives me error:
Index exceeds matrix dimensions.
Error in protA_select2>protA_select2_OpeningFcn (line 68)
stageNo = varargin{1};
Error in gui_mainfcn (line 220)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
Error in figure2 (line 40)
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
Error in figure2>cancelbutton_Callback (line 690)
close(figure2)
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in protA_select2 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)figure2('cancelbutton_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
Anyone ever experience this before?
I make the GUI via guide and for some reasons, I need to pass the input without setappdata.
Thanks a lot! :)
Elizabeth
0 Kommentare
Akzeptierte Antwort
Adam
am 11 Mai 2016
Bearbeitet: Adam
am 11 Mai 2016
'figure2' is not defined in that scope.
I assume you want to use
handles.figure2
as the handle of your GUI to close.
2 Kommentare
Adam
am 12 Mai 2016
A GUIDE GUI you should close using the tag. I am surprised
close( name )
would ever work in that context because 'figure2' would just be expected to be a variable like any other.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!