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

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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2017년 3월 29일
편집: Jan 2017년 3월 29일
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

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2017년 3월 29일

댓글:

Jan
2017년 3월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by