some errors while execute GUI mxArray must be double, char, or cell

1 view (last 30 days)
Hello while i execute my program some errors occured Error using set error: mxArray must be double, char, or cell
Error in cursor/set (line 15) builtin('set',h,p,v)
Error in Fuzzy_Query_GUI>Fuzzy_Query_GUI_OpeningFcn (line 64) set(handles.age_list,'String', fetch(select_age));

Answers (1)

Geoff Hayes
Geoff Hayes on 7 Sep 2014
Edited: Geoff Hayes on 7 Sep 2014
Yasser - the error message Error using set error: mxArray must be double, char, or cell is indicating that the data that you are using to set in the String property of the list box widget is invalid. Valid inputs are double, char or cell. (I can get the same error if I try to set this property with a structure.)
The return value from the fetch is a cursor object. One of the examples from the link shows what this object looks like
curs = exec(conn,'select productDescription from productTable');
curs = fetch(curs)
Data: {10x1 cell}
RowLimit: 0
SQLQuery: 'select productDescription from productTable'
Message: []
Type: 'ODBCCursor Object'
Statement: [1x1 database.internal.ODBCStatementHandle]
The above uses an ODBC connection, so may be different for your case. But the importance of the above is the Data field in the cursor object (which is probably common to all cursors). It is a 10x1 cell structure which seems that it could be a likely candidate to populate your list box.
Try the following
% fetch the results of the SQL query
cursorObj = fetch(select_age);
% extract the data
data = cursorObj.Data;
% if something in the data then try to use it
if ~isempty(data)
set(handles.age_list,'String', data);
end
% close the cursor object
close(cursorObj);
Note that the above assumes that the data cell array has multiple rows and one column, and can easily fit into a list box.

Products

Community Treasure Hunt

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

Start Hunting!