Index exceeds matrix dimensions error

i have database named 'data' , in gui i have 3 editbox which are name,gpa,salary and a push button . have data in database like this :
field= {'name','gpa','salary'};
data = {'Andre',3.2,$1000};
my program like this :
conn = database('db1_mysql','root','');
sql = ['select * from data where name =','''',handles.name,''''];
data = fetch(conn,sql)
handles.data = data;
guidata(hObject,handles)
if isempty(data)
msgbox('data not found')
set(handles.gpa,'String','')
set(handles.salary,'String','')
else
set(handles.gpa,'String',data(1,2))
set(handles.salary,'String',data(1,3))
end
what i want is if i type Andre in name editbox in gui , his gpa and salary show up in others edit box . but i'm getting error : Index exceeds matrix dimensions. my database have 1 row , and 3 coloumn . how can it not working . Im using matlab R2016a

4 comentarios

per isakson
per isakson el 14 de Sept. de 2016
Walter Roberson
Walter Roberson el 14 de Sept. de 2016
'$' can only occur in MATLAB inside a string or a comment. Is the third part of your data intended to be a string?
Walter Roberson
Walter Roberson el 14 de Sept. de 2016
What shows up for size(data) and class(data) ?
Brendan Hamm
Brendan Hamm el 15 de Sept. de 2016
Seems to be a duplicate problem with a minor difference in the example. The issue is exactly the same though.

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

el 14 de Sept. de 2016

Comentada:

el 15 de Sept. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by