필터 지우기
필터 지우기

a GUI keeps popping out after close command

조회 수: 2 (최근 30일)
Elizabeth
Elizabeth 2016년 5월 11일
댓글: Adam 2016년 5월 12일
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

채택된 답변

Adam
Adam 2016년 5월 11일
편집: Adam 2016년 5월 11일
'figure2' is not defined in that scope.
I assume you want to use
handles.figure2
as the handle of your GUI to close.
  댓글 수: 2
Elizabeth
Elizabeth 2016년 5월 12일
Hello, Adam! Thanks for your help!
Usually I write
close(name)
to close the figure. In this case, the name is figure2. Does it have to do with the tag name? Because I just tried your suggestion with
close(handles.tag)
and it works.
I have another gui file made in GUIDE that works also with only close(filename). However, this particular file does not have input argument. Thanks a lot anyway! :)
Adam
Adam 2016년 5월 12일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by