2015-05-06 15 views
1

我有一個表:表Matlab的:卡住單元類型在表元素

>> T2 
T2 = 
    Eyetraction  Statues 
    ____________ _______ 
    'Distractor' 0  
    'Distractor' 0  
    'Other'   0  
    'Other'   0  
    'Distractor' 0  
    'Target'  0  
    'Other'   0  
    'Distractor' 0  
    'Other'   0  
    'Target'  0 

doc table,根據第訪問數據,它表明,我可以使用邏輯表達式獲得布爾數組索引,如:

rows = T2.Eyetraction=='Other' 

但是,我得到了一個錯誤:

Undefined function 'eq' for input arguments of type 'cell'. 

然後我試圖使用電池的索引,但仍然得到錯誤:

>> T2.Eyetraction{:}=='Other' 
Error using == 
Matrix dimensions must agree. 

我的直覺告訴我,改變細胞的字符串,但是:

>> class(cellstr(T2.Eyetraction(2))) 
ans = 
cell 
>> % -------- Cell '{}' indexing? 
>> class(cellstr(T2.Eyetraction{2})) 
ans = 
cell 

這不應該是正確的。

回答

2

您的第一列包含字符串。試試這個,find(ismember(T2.Eyetraction,'Other'))

+0

謝謝! 'ismember'(沒有'find()')的作品,我現在就用它。 –

+1

如果解決了您的問題,請接受答案。 –