I can't get GUI text entry
Mostrar comentarios más antiguos
hello
_ knowing that many people posted the same problem but no working solution has been proposed._
I got this error "Attempt to reference field of non-structure array" when I try get the input from GUI.
I made a simple GUI (edit1 and pushbutton1) in order to see if the problem is from my first GUI then I make necessary corrections.
Unfortunately, I got the same error.
Here is the code of the simple GUI. I didn't change anything in what GUIDE generated except deleting unnecessary comments.
Any thoughts about this.
function varargout = untitled(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%opening function
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%output function
function varargout = untitled_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%push button callback function
function pushbutton1_Callback(hObject, eventdata, handles)
W(1).name = get(handles.edit1,'string');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%edit textbox callback function
function edit1_Callback(hObject, eventdata, handles)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%edit textbox create function
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
2 comentarios
Sivakumaran Chandrasekaran
el 12 de En. de 2016
when i run this code, it throws error stating, no gui present. mail me the code and gui to siva@photontech.net
Abdelmoumen Bacetti
el 12 de En. de 2016
Respuestas (1)
Image Analyst
el 12 de En. de 2016
0 votos
It looks okay. The only thing I think might possibly be wrong is the (1). Try using W.name instead of W(1).name and see if that works. If not, attach both the fig file and m file with the paper clip icon.
By the way, with just that code you've shown, you won't be able to access W once that callback exits.
4 comentarios
Abdelmoumen Bacetti
el 12 de En. de 2016
Abdelmoumen Bacetti
el 12 de En. de 2016
Image Analyst
el 12 de En. de 2016
So you just put it into W but never do anything with it afterwards. Do you ever want to use it again? If so, see the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
Abdelmoumen Bacetti
el 12 de En. de 2016
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!