set and get on two gui

4 views (last 30 days)
pink
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);
inputmaterial=get(handles.applybutton,'UserData')
set(mainGUIdata.table1,'data',inputmaterial)
guidata(main, mainGUIdata);
close

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;
or
mainGUIhandle = handles.figure1;

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!