matlab获取错误“来自非单元数组对象的单元格内容引用”

时间:2014-02-26 06:14:45

标签: matlab cell

我有一个矩阵

y = auto air condit freon articl hvx new cso uiuc edu tspila uxa cso uiuc edu tim spila romulan write articl apr ntuix ntu mgqlu ntuix ntu max write work ga solid adsorpt air con system for auto applic thi kind system energi for regener adsorb exhaust ga interest thi mail email follow thi thread discuss prospect thi technolog bite thi suppos work tim year ago demonstr cold air system us air call rovax unit work short come seal technolog todai

<<大小(Y)

ans =

 1   442

我还有另一个矩阵tokenVector为

tokenVector = 

第1至6栏

'abandon'    'abomin'    'aborigin'    'abraham'    'abruptli'    'absenc'

第7至13栏

'absolut'    'absurd'    'abus'    'academi'    'acc'    'accept'    'accesori'

当我使用ismember(y,tokenVector)时,我收到错误:

"Cell contents reference from a non-cell array object".

我没有意义错误。请帮助我是matlab的新手。

1 个答案:

答案 0 :(得分:2)

我假设您的y只是一个字符串,即声明为

y = 'auto air condit freon ar...'

在这种情况下,您只需先调用strsplit将其拆分为单词的单元格矩阵:

ismember( strsplit(y,' '), tokenVector)

错误告诉您需要使用cell array作为输入而不是简单的char数组。 strsplit函数会根据特定的分隔符(在本例中为空格' ')将char数组拆分为单元数组。

相关问题