GUI:Struct contents reference from a non-struct array object.

I cannot display the result on the editable module like "edit1".
I only list core sentences in my GUI function named untitled1, and with this function, I want to display a string on the "edit1" when I push the button "pushbutton1"
function varargout = untitled1(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled1_OpeningFcn, ...
'gui_OutputFcn', @untitled1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function untitled1_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = untitled1_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function pushbutton1_Callback(hObject, eventdata, handles)
set(handles.edit1,'string','r')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function edit1_Callback(hObject, eventdata, handles)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
The problem is: Struct contents reference from a non-struct array object.
Error in untitled1>pushbutton1_Callback (line 81) set(handles.edit1,'string','r')"
Also it sometimes occurs "Reference to non-existent field 'edit1'."

2 comentarios

ES
ES el 29 de Mzo. de 2017
you have the edit box 'edit1' in the GUI right? because, other than that, your code looks completely fine.
Please post the complete error message. While it is clear where the "edit1" problem occurres, we cannot guess the source of the "reference from a non-struct array object" error.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 29 de Mzo. de 2017
Editada: Jan el 29 de Mzo. de 2017
Set a breakpoint in the failing line. Then run your code again. If it stops in this line, examine the value of handles:
disp(handles)
The message means, that the field "edit1" does not exist. Perhaps it has another name or there is not "edit1" object in the GUI?
Anyway, learning to use the debugger is essential. Please read Debug a Matlab program

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

el 29 de Mzo. de 2017

Comentada:

Jan
el 29 de Mzo. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by