for loop is not working in my program
조회 수: 4 (최근 30일)
이전 댓글 표시
Sir/Madam, I need help to execute for loop. Please help me. this program can't check about the user is exists or not.. Please help me where I'm wrong.
function varargout = home(varargin)
% HOME MATLAB code for home.fig
% HOME, by itself, creates a new HOME or raises the existing
% singleton*.
%
% H = HOME returns the handle to a new HOME or the handle to
% the existing singleton*.
%
% HOME('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in HOME.M with the given input arguments.
%
% HOME('Property','Value',...) creates a new HOME or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before home_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to home_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 home
% Last Modified by GUIDE v2.5 27-Mar-2017 10:36:35
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @home_OpeningFcn, ...
'gui_OutputFcn', @home_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 home is made visible.
function home_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 home (see VARARGIN)
% Choose default command line output for home
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
end
% UIWAIT makes home wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = home_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
function user_name_Callback(hObject, eventdata, handles)
% hObject handle to user_name (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 user_name as text
% str2double(get(hObject,'String')) returns contents of user_name as a double
guidata(hObject, handles);
end
% --- Executes during object creation, after setting all properties.
function user_name_CreateFcn(hObject, eventdata, handles)
% hObject handle to user_name (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
% --- 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'));
run('signup');
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.user_name,'String');
%edit1 being Tag of ur edit box
if isempty(uname1)
% errordlg('Please enter Username');
uiwait(warndlg('Please Enter Username'));
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('hallo');
% Create figure
user_name_exist=1;
disp(user_name_exist);
disp('hai');
break;
else
user_name_exist=0;
%figure('Name','imgsel.fig');
end
end
if(user_name_exist==1)
% Image_mag(handles.uname);
% fig=run('Image_mag.m','reuse','visible');
%set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));
run('Image_mag')
% 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
end
% --- Executes on button press in cancel.
function cancel_Callback(hObject, eventdata, handles)
% hObject handle to cancel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close
end
댓글 수: 0
채택된 답변
Jan
2017년 3월 27일
The only for loop in the code is:
for i = numel(curs.Data)
It runs for 1 iteration only. Perhaps you want:
for i = 1:numel(curs.Data)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!