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 个评论
ES
2017-3-29
you have the edit box 'edit1' in the GUI right? because, other than that, your code looks completely fine.
Jan
2017-3-29
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 个)
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?
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!