Matlab错误 - 来自非单元数组对象的单元格内容引用

时间:2015-05-26 03:48:18

标签: matlab ms-access

为什么从非单元数组对象中获取错误单元格内容引用。以下是我的代码。谁能告诉我这段代码有什么问题?

%Read data from database.
curs = exec(conn, sprintf(['SELECT   description.imageName'...
    ' , description.brand'...
    ' , description.price'...
    ' , description.size'...
    ' , description.clothingDescription'...
    ' FROM  description WHERE description.imageID ="%s"'],imagename));

curs = fetch(curs);
close(curs);

%Assign data to output variable
results = curs.Data; 
disp(results);

set(handles.edit1,'String',results{1}); 
set(handles.edit2,'String',results{2});
set(handles.edit3,'String',results{3});
set(handles.edit4,'String',results{4}); 
set(handles.edit5,'String',results{5});

这是完整的错误消息

Cell contents reference from a non-cell array object.

Error in image_desc1>image_desc1_OpeningFcn (line 90)
set(handles.edit1,'String',results{1});

Error in gui_mainfcn (line 220)
    feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

Error in image_desc1 (line 42)
    gui_mainfcn(gui_State, varargin{:});

中输入代码时, 其中一个示例数据在命令窗口中执行
WHERE description.imageID =1

'高领T恤' ' ZALORA' [40]' S,M,L,XL' ' ZALORA'

腮红高领

输入whos后,它会在命令窗口中显示这句话

Name         Size            Bytes  Class     Attributes

  results      1x1                 8  double 

1 个答案:

答案 0 :(得分:0)

错误清楚地传达了消息。变量results不是单元格数组,您尝试提取不存在的results{1},...,results{5}。因此错误。