MATLAB Answers

set and get on two gui

14 views (last 30 days)
pink on 12 Jun 2011
I made two gui, gui A (input) and gui B (table), when I enter data into gui B, the data is lost and only appear later in case of error, so I need your advice
??? Error using ==> setappdata Invalid object handle
Error in ==> gui_mainfcn at 242 setappdata(gui_hFigure,'GUIOnScreen', 1);
Error in ==> main at 40 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
Error in ==> inputmaterial>okbutton_Callback at 77 mainGUIhandle = main;
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> inputmaterial at 16 gui_mainfcn(gui_State, varargin{:});
my code
function okbutton_Callback(hObject, eventdata, handles)
% hObject handle to okbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mainGUIhandle = main;
mainGUIdata = guidata(mainGUIhandle);
guidata(main, mainGUIdata);

Accepted Answer

Paulo Silva
Paulo Silva on 12 Jun 2011
The error is in the line:
mainGUIhandle = main;
In that context MATLAB doesn't know what the variable main is because it's not defined, maybe you can use:
mainGUIhandle = gcf;
mainGUIhandle = handles.figure1;

More Answers (0)


Community Treasure Hunt

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

Start Hunting!