How to got correct answer in if condition in GUI?
Mostrar comentarios más antiguos
Hi, after retrieve all data about driver got other problem, with if condition. When car number plate correct if condition work great, but if i do task that car number plate not in database i got error. Please help me, where i do mistake. Code add below. P.S. Sorry for my bad english
conn = database('baze', 'root', 'root', 'Vendor', 'MYSQL', 'Server', 'localhost', 'PortNumber', 3306);
setdbprefs('datareturnformat','structure');
word = get(handles.edit4,'String');
if iscell(word) && numel(word) == 1
word = word{1};
end
if ~ischar(word) || isempty(word);
error('A valid string must be supplied!');
end
sqlquery = ['select vardas, pavarde, laipsnis, pareigos, telefonas, marke, numeris, tarnyba, nuotrauka from info '...
'where numeris = ' '''' word ''''];
curs = exec(conn, sqlquery);
setdbprefs('DataReturnFormat','cellarray');
curs = fetch(curs);
numeris = curs.data{1,7};
vardas = curs.data{1,1};
pavarde = curs.data{1,2};
laipsnis = curs.data{1,3};
pareigos = curs.data{1,4};
telefonas = curs.data{1,5};
marke = curs.data{1,6};
tarnyba = curs.data{1,8};
nuotrauka = curs.data(1,9);
set(handles.edit5,'string',vardas);
set(handles.edit6,'string',pavarde);
set(handles.edit7,'string',laipsnis);
set(handles.edit8,'string',pareigos);
set(handles.edit9,'string',telefonas);
set(handles.edit10,'string',marke);
set(handles.edit11,'string',numeris);
set(handles.edit12,'string',tarnyba);
axes(handles.axes4);
nuotrauka = nuotrauka{1};
jimage = javax.imageio.ImageIO.read(java.io.ByteArrayInputStream(typecast(nuotrauka, 'uint8')));
height = jimage.getHeight;
width = jimage.getWidth;
pixels = reshape(typecast(jimage.getData.getDataStorage, 'uint8'), [3,width,height]);
img = cat(3, ...
transpose(reshape(pixels(3,:,:), [width,height])), ...
transpose(reshape(pixels(2,:,:), [width,height])), ...
transpose(reshape(pixels(1,:,:), [width,height])));
imshow(img);
a = ('ENTRY');
b = ('DO NOT ENTRY');
if word == curs.data{1,7}
set(handles.text13,'foregroundcolor','green');
set(handles.text13,'string',a);
else
set(handles.text13,'foregroundcolor','red');
set(handles.text13,'string',b);
end
close(curs);
close(conn);
clear all
2 comentarios
Jan
el 18 de Dic. de 2016
If you get an error message, please post a complete copy of it. It is much easier to understand a problem, if it is known.
Gytis Raudonius
el 20 de Dic. de 2016
Respuesta aceptada
Más respuestas (2)
Jan
el 18 de Dic. de 2016
A bold guess:
if word == curs.data{1,7}
Do not compare strings by ==, but with strcmp
if strcmp(word, curs.data{1,7})
3 comentarios
Gytis Raudonius
el 20 de Dic. de 2016
Jan
el 26 de Dic. de 2016
Please do not let us guess, but post the error message you get. In the shown code you compare "word" with "curs.data{1,7}" twice.
Gytis Raudonius
el 26 de Dic. de 2016
Gytis Raudonius
el 30 de Dic. de 2016
Categorías
Más información sobre Semantic Segmentation 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!