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_responsecase {'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
Best Answer