MATLAB: I’m getting an error is Attempt to reference field of non-structure array.

attempt to reference field of non-structure array

function varargout = user_name(varargin) % USER_NAME MATLAB code for user_name.fig % USER_NAME, by itself, creates a new USER_NAME or raises the existing % singleton*. % % H = USER_NAME returns the handle to a new USER_NAME or the handle to % the existing singleton*. % % USER_NAME('CALLBACK',hObject,eventData,handles,…) calls the local % function named CALLBACK in USER_NAME.M with the given input arguments. % % USER_NAME('Property','Value',…) creates a new USER_NAME or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before user_name_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to user_name_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help user_name
% Last Modified by GUIDE v2.5 20-Mar-2017 14:49:24
% Begin initialization code – DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, … 'gui_Singleton', gui_Singleton, … 'gui_OpeningFcn', @user_name_OpeningFcn, … 'gui_OutputFcn', @user_name_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 % End initialization code – DO NOT EDIT end
% — Executes just before user_name is made visible. function user_name_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved – to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to user_name (see VARARGIN)
% Choose default command line output for user_name handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% UIWAIT makes user_name wait for user response (see UIRESUME) % uiwait(handles.figure1);
end % — Outputs from this function are returned to the command line. function varargout = user_name_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved – to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure varargout{1} = handles.output;
end % — Executes on button press in Signup. function Signup_Callback(hObject, eventdata, handles) % hObject handle to Signup (see GCBO) % eventdata reserved – to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) fig=openfig('signup','reuse','visible'); set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));
end
% — Executes on button press in signin. function signin_Callback(hObject, eventdata, handles) % hObject handle to signin (see GCBO) % eventdata reserved – to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global user_name_exist; uname1 = get(handles.uname,'String'); %edit1 being Tag of ur edit box if isempty(uname1) % errordlg('Please enter Username'); uiwait(warndlg('Please Enter Username')); end conn = database('mani','root','MARUTHI'); curs=exec(conn,'select uname from user2'); curs=fetch(curs);curs.Data
for i=numel(curs.Data) if(strcmp(curs.Data(i),uname1)) disp(curs.Data(i)) % Create figure user_name_exist=1; disp(user_name_exist); disp('hai'); break;
else
user_name_exist=0;
continue;%figure('Name','imgsel.fig');
end
end
if(user_name_exist==1)
% Image_mag(handles.uname);
fig=openfig('Image_mag','reuse','visible');
set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));
% handles.fig=figure('Units','Pixels', ...
% 'Position',[100 100 500 500]);
% msgbox(size(curs.Data));
%han1111dles.signin=Image_mag;
%set(handles.fig,Image_mag,{ImagesExample,handles});
else
uiwait(warndlg('Please enter a valid User name'));
end
close(curs);
close(conn);
end
function uname_Callback(hObject, eventdata, handles) % hObject handle to uname (see GCBO) % eventdata reserved – to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of uname as text % str2double(get(hObject,'String')) returns contents of uname as a double guidata(hObject, handles);
end
% — Executes during object creation, after setting all properties. function uname_CreateFcn(hObject, eventdata, handles) % hObject handle to uname (see GCBO) % eventdata reserved – to be defined in a future version of MATLAB % handles empty – handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
end
I written the above code and execute well yesterday,but today while executing this code Attempt to reference field of non-structure array.
Attempt to reference field of non-structure array.
Error in signup>submit1_Callback (line 106) uname1 = get(handles.u_name,'String');
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in signup (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)signup('submit1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Please help me…..

Best Answer

I'm getting error in signup.m is "attempt to reference field of non-structure array." and in the user_name.m file have a for loop that is not at all executing... Please help me the code for working properly.
Attempt to reference field of non-structure array.
Error in signup>submit1_Callback (line 106)
uname1 = get(handles.u_name,'String');
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in signup (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)signup('submit1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Related Question