set and get on two gui

1 vue (au cours des 30 derniers jours)
pink
pink le 12 Juin 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

Réponse acceptée

Paulo Silva
Paulo Silva le 12 Juin 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;

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by