2014-02-26 53 views
1

我有一個矩陣作爲MATLAB得到錯誤「單元格內容從非單元陣列對象引用」

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新手。

回答

2

我假設你y只是即聲明爲

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

在這種情況下,你只需要調用strsplit首先將它拆分成詞的細胞基質的字符串:

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

錯誤告訴你,你需要使用cell array作爲輸入,而不是簡單的char數組。基於特定的分隔符,strsplit函數會將char數組拆分爲單元格數組,在這種情況下,該空間爲' '